UNPKG

xiot-core-spec-ts

Version:
43 lines (42 loc) 2.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ServiceImageCodec = void 0; const Spec_1 = require("../../typedef/constant/Spec"); const ServiceImage_1 = require("../../typedef/image/ServiceImage"); const ServiceType_1 = require("../../typedef/definition/urn/ServiceType"); const DescriptionCodec_1 = require("../definition/DescriptionCodec"); const PropertyImageCodec_1 = require("./PropertyImageCodec"); const ActionImageCodec_1 = require("./ActionImageCodec"); const EventImageCodec_1 = require("./EventImageCodec"); class ServiceImageCodec { static decodeArray(array) { const list = []; if (array != null) { for (const o of array) { const iid = o[Spec_1.Spec.IID]; const type = new ServiceType_1.ServiceType(o[Spec_1.Spec.TYPE]); const description = DescriptionCodec_1.DescriptionCodec.decode(o[Spec_1.Spec.DESCRIPTION]); const properties = PropertyImageCodec_1.PropertyImageCodec.decodeArray(o[Spec_1.Spec.PROPERTIES]); const actions = ActionImageCodec_1.ActionImageCodec.decodeArray(o[Spec_1.Spec.ACTIONS]); const events = EventImageCodec_1.EventImageCodec.decodeArray(o[Spec_1.Spec.EVENTS]); // if (o[Spec.X_OPTIONAL] != null) { // type._optional = o[Spec.X_OPTIONAL]; // } // if (o[Spec.X_PROPERTY_ADDABLE] != null) { // type._property_addable = o[Spec.X_PROPERTY_ADDABLE]; // } // // if (o[Spec.X_ACTION_ADDABLE] != null) { // type._action_addable = o[Spec.X_ACTION_ADDABLE]; // } // // if (o[Spec.X_EVENT_ADDABLE] != null) { // type._event_addable = o[Spec.X_EVENT_ADDABLE]; // } list.push(new ServiceImage_1.ServiceImage(iid, type, description, properties, actions, events)); } } return list; } } exports.ServiceImageCodec = ServiceImageCodec;