Esempio n. 1
0
        public static IDeviceMember ParseMember(DeviceObject parentObject, JObject inputNode)
        {
            switch (inputNode.Value <string>("type"))
            {
            case "object":
                return(DeviceObject.CreateFrom(parentObject, inputNode));

            case "function":
                return(DeviceFunction.CreateFrom(inputNode));

            default:
                return(DeviceProperty.CreateFrom(inputNode));
            }
        }
        public static DeviceFunction CreateFrom(int id, string name, JArray argumentNodes, JArray inputNodes, JArray outputNodes)
        {
            var deviceFunction = new DeviceFunction
            {
                ID   = id,
                Name = name,
                Type = DataType.Function
            };

            var arguments = new List <DeviceProperty>();
            var inputs    = new List <DeviceProperty>();
            var outputs   = new List <DeviceProperty>();

            if (argumentNodes != null)
            {
                foreach (dynamic node in argumentNodes)
                {
                    arguments.Add(DeviceProperty.CreateFrom(node));
                }
            }

            if (inputNodes != null)
            {
                foreach (dynamic node in inputNodes)
                {
                    inputs.Add(DeviceProperty.CreateFrom(node));
                }
            }

            if (outputNodes != null)
            {
                foreach (dynamic node in outputNodes)
                {
                    outputs.Add(DeviceProperty.CreateFrom(node));
                }
            }

            deviceFunction.Arguments = arguments;
            deviceFunction.Inputs    = inputs;
            deviceFunction.Outputs   = outputs;

            return(deviceFunction);
        }