Ejemplo n.º 1
0
        private UaValue BuildInnerComplex(string description, int length, bool generateSchema)
        {
            if (length == 1)
            {
                return(BuildJsonForObject(description, generateSchema));
            }

            var     jArray = new JArray();
            UaValue uaVal  = new UaValue();

            for (int i = 0; i < length; i++)
            {
                uaVal = BuildJsonForObject(description, generateSchema);
                jArray.Insert(i, uaVal.Value);
            }

            var jSchema = (generateSchema) ? DataTypeSchemaGenerator.GenerateSchemaForArray(new[] { length }, uaVal.Schema) : null;

            return(new UaValue(jArray, jSchema));
        }
Ejemplo n.º 2
0
        private UaValue BuildSimple(string type, int length, bool generateSchema)
        {
            var builtinType = DataTypeAnalyzer.GetBuiltinTypeFromTypeName(type.Split(':')[0], type.Split(':')[1]);
            var jSchema     = generateSchema ? DataTypeSchemaGenerator.GenerateSchemaForStandardTypeDescription(builtinType) : null;

            if (length == 1)
            {
                var jValue = JToken.FromObject(ReadBuiltinValue(builtinType));
                return(new UaValue(jValue, jSchema));
            }

            var a = new List <object>();

            for (int i = 0; i < length; i++)
            {
                a.Add(ReadBuiltinValue(builtinType));
            }

            var arrSchema = generateSchema ? DataTypeSchemaGenerator.GenerateSchemaForArray(new[] { length }, jSchema) : null;

            return(new UaValue(JToken.FromObject(a), arrSchema));
        }