Example #1
0
        public bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode <JsonValue> value)
        {
            switch (key)
            {
            case "multipleOf":
                MultipleOf = value.GetInt32();
                return(true);

            case "maximum":
                Maximum = value.GetInt32();
                return(true);

            case "exclusiveMaximum":
                ExclusiveMaximum = value.GetBoolean();
                return(true);

            case "minimum":
                Minimum = value.GetInt32();
                return(true);

            case "exclusiveMinimum":
                ExclusiveMinimum = value.GetBoolean();
                return(true);
            }

            return(false);
        }
        public bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode <JsonValue> value)
        {
            switch (key)
            {
            case "maxProperties":
                MaxProperties = value.GetInt32();
                return(true);

            case "minProperties":
                MinProperties = value.GetInt32();
                return(true);

            case "required":
            {
                foreach (var req in value.ArrayItems())
                {
                    m_required.Add(req.GetString());
                }
            }
                return(true);

            case "properties":
            {
                foreach (var prop in value.ObjectItems())
                {
                    AddProperty(fs, prop.Key.GetString(), prop.Value);
                }
            }
                return(true);

            case "patternProperties":
                PatternProperties = value.GetString();
                return(true);

            case "additionalProperties":
            {
                var sub = new JsonSchema();
                sub.Parse(fs, value, "additionalProperties");
                AdditionalProperties = sub;
            }
                return(true);

            case "dependencies":
            {
                foreach (var kv in value.ObjectItems())
                {
                    Dependencies.Add(kv.Key.GetString(), kv.Value.ArrayItems().Select(x => x.GetString()).ToArray());
                }
            }
                return(true);

            case "propertyNames":
                return(true);
            }

            return(false);
        }
        public static object DefaultDictionaryDeserializer(ListTreeNode <T> s)
        {
            switch (s.Value.ValueType)
            {
            case ValueNodeType.Object:
            {
                var u = new Dictionary <string, object>();
                foreach (var kv in s.ObjectItems())
                {
                    //var e = default(object);
                    //kv.Value.Deserialize(ref e);
                    u.Add(kv.Key.GetString(), DefaultDictionaryDeserializer(kv.Value));
                }
                return(u);
            }

            case ValueNodeType.Null:
                return(null);

            case ValueNodeType.Boolean:
                return(s.GetBoolean());

            case ValueNodeType.Integer:
                return(s.GetInt32());

            case ValueNodeType.Number:
                return(s.GetDouble());

            case ValueNodeType.String:
                return(s.GetString());

            default:
                throw new NotImplementedException(s.Value.ValueType.ToString());
            }
        }
Example #4
0
        public bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode <JsonValue> value)
        {
            switch (key)
            {
            case "maxLength":
                MaxLength = value.GetInt32();
                return(true);

            case "minLength":
                MinLength = value.GetInt32();
                return(true);

            case "pattern":
                Pattern = new Regex(value.GetString().Replace("\\\\", "\\"));
                return(true);
            }

            return(false);
        }
Example #5
0
        public bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode <JsonValue> value)
        {
            switch (key)
            {
            case "items":
                if (value.IsArray())
                {
                    throw new NotImplementedException();
                }
                else
                {
                    var sub = new JsonSchema();
                    sub.Parse(fs, value, "items");
                    Items = sub;
                }
                return(true);

            case "additionalItems":
                return(true);

            case "maxItems":
                MaxItems = value.GetInt32();
                return(true);

            case "minItems":
                MinItems = value.GetInt32();
                return(true);

            case "uniqueItems":
                return(true);

            case "contains":
                return(true);
            }

            return(false);
        }
Example #6
0
 public void Deserialize <T, U>(ListTreeNode <T> src, ref U dst)
     where T : IListTreeItem, IValue <T>
 {
     dst = GenericCast <int, U> .Cast(src.GetInt32());
 }