Example #1
0
 public JsonSchemaNode AddSchema(JsonSchemaNode existingNode, JsonSchema schema)
 {
   string id;
   if (existingNode != null)
   {
     if (existingNode.Schemas.Contains(schema))
       return existingNode;
     id = JsonSchemaNode.GetId(Enumerable.Union<JsonSchema>((IEnumerable<JsonSchema>) existingNode.Schemas, (IEnumerable<JsonSchema>) new JsonSchema[1]
     {
       schema
     }));
   }
   else
     id = JsonSchemaNode.GetId((IEnumerable<JsonSchema>) new JsonSchema[1]
     {
       schema
     });
   if (this._nodes.Contains(id))
     return this._nodes[id];
   JsonSchemaNode jsonSchemaNode = existingNode != null ? existingNode.Combine(schema) : new JsonSchemaNode(schema);
   this._nodes.Add(jsonSchemaNode);
   this.AddProperties(schema.Properties, (IDictionary<string, JsonSchemaNode>) jsonSchemaNode.Properties);
   this.AddProperties(schema.PatternProperties, (IDictionary<string, JsonSchemaNode>) jsonSchemaNode.PatternProperties);
   if (schema.Items != null)
   {
     for (int index = 0; index < schema.Items.Count; ++index)
       this.AddItem(jsonSchemaNode, index, schema.Items[index]);
   }
   if (schema.AdditionalProperties != null)
     this.AddAdditionalProperties(jsonSchemaNode, schema.AdditionalProperties);
   if (schema.Extends != null)
     jsonSchemaNode = this.AddSchema(jsonSchemaNode, schema.Extends);
   return jsonSchemaNode;
 }
Example #2
0
 public JsonSchemaModel Build(JsonSchema schema)
 {
   this._nodes = new JsonSchemaNodeCollection();
   this._node = this.AddSchema((JsonSchemaNode) null, schema);
   this._nodeModels = new Dictionary<JsonSchemaNode, JsonSchemaModel>();
   return this.BuildNodeModel(this._node);
 }
        public JsonSchemaNode AddSchema(JsonSchemaNode existingNode, JsonSchema schema)
        {
            string newId;
            if (existingNode != null)
            {
                if (existingNode.Schemas.Contains(schema))
                {
                    return existingNode;
                }

                newId = JsonSchemaNode.GetId(existingNode.Schemas.Union(new[] { schema }));
            }
            else
            {
                newId = JsonSchemaNode.GetId(new[] { schema });
            }

            if (_nodes.Contains(newId))
            {
                return _nodes[newId];
            }

            JsonSchemaNode currentNode = (existingNode != null)
                ? existingNode.Combine(schema)
                : new JsonSchemaNode(schema);

            _nodes.Add(currentNode);

            AddProperties(schema.Properties, currentNode.Properties);

            AddProperties(schema.PatternProperties, currentNode.PatternProperties);

            if (schema.Items != null)
            {
                for (int i = 0; i < schema.Items.Count; i++)
                {
                    AddItem(currentNode, i, schema.Items[i]);
                }
            }

            if (schema.AdditionalItems != null)
            {
                AddAdditionalItems(currentNode, schema.AdditionalItems);
            }

            if (schema.AdditionalProperties != null)
            {
                AddAdditionalProperties(currentNode, schema.AdditionalProperties);
            }

            if (schema.Extends != null)
            {
                foreach (JsonSchema jsonSchema in schema.Extends)
                {
                    currentNode = AddSchema(currentNode, jsonSchema);
                }
            }

            return currentNode;
        }
        public void AddProperty(JsonSchemaNode parentNode, string propertyName, JsonSchema schema)
        {
            JsonSchemaNode propertyNode;
              parentNode.Properties.TryGetValue(propertyName, out propertyNode);

              parentNode.Properties[propertyName] = AddSchema(propertyNode, schema);
        }
Example #5
0
 public void AddItem(JsonSchemaNode parentNode, int index, JsonSchema schema)
 {
   JsonSchemaNode jsonSchemaNode = this.AddSchema(parentNode.Items.Count > index ? parentNode.Items[index] : (JsonSchemaNode) null, schema);
   if (parentNode.Items.Count <= index)
     parentNode.Items.Add(jsonSchemaNode);
   else
     parentNode.Items[index] = jsonSchemaNode;
 }
    private JsonSchemaNode(JsonSchemaNode source, JsonSchema schema)
    {
      Schemas = new ReadOnlyCollection<JsonSchema>(source.Schemas.Union(new[] { schema }).ToList());
      Properties = new Dictionary<string, JsonSchemaNode>(source.Properties);
      Items = new List<JsonSchemaNode>(source.Items);
      AdditionalProperties = source.AdditionalProperties;

      Id = GetId(Schemas);
    }
Example #7
0
        public JsonSchemaModel Build(JsonSchema schema)
        {
            _nodes = new JsonSchemaNodeCollection();
            _node = AddSchema(null, schema);

            _nodeModels = new Dictionary<JsonSchemaNode, JsonSchemaModel>();
            JsonSchemaModel model = BuildNodeModel(_node);

            return model;
        }
Example #8
0
 private JsonSchemaNode(JsonSchemaNode source, JsonSchema schema)
 {
     Schemas = new ReadOnlyCollection <JsonSchema>(source.Schemas.Union(new JsonSchema[1] {
         schema
     }).ToList());
     Properties           = new Dictionary <string, JsonSchemaNode>(source.Properties);
     PatternProperties    = new Dictionary <string, JsonSchemaNode>(source.PatternProperties);
     Items                = new List <JsonSchemaNode>(source.Items);
     AdditionalProperties = source.AdditionalProperties;
     Id = GetId(Schemas);
 }
 // Token: 0x060009E8 RID: 2536
 // RVA: 0x0003EDD0 File Offset: 0x0003CFD0
 public void AddItem(JsonSchemaNode parentNode, int index, JsonSchema schema)
 {
     JsonSchemaNode existingNode = (parentNode.Items.Count > index) ? parentNode.Items[index] : null;
     JsonSchemaNode jsonSchemaNode = this.AddSchema(existingNode, schema);
     if (parentNode.Items.Count <= index)
     {
         parentNode.Items.Add(jsonSchemaNode);
         return;
     }
     parentNode.Items[index] = jsonSchemaNode;
 }
Example #10
0
 private JsonSchemaNode(JsonSchemaNode source, JsonSchema schema)
 {
     JsonSchema[] second = new JsonSchema[] { schema };
     this.Schemas              = new ReadOnlyCollection <JsonSchema>(source.Schemas.Union <JsonSchema>(second).ToList <JsonSchema>());
     this.Properties           = new Dictionary <string, JsonSchemaNode>(source.Properties);
     this.PatternProperties    = new Dictionary <string, JsonSchemaNode>(source.PatternProperties);
     this.Items                = new List <JsonSchemaNode>(source.Items);
     this.AdditionalProperties = source.AdditionalProperties;
     this.AdditionalItems      = source.AdditionalItems;
     this.Id = GetId(this.Schemas);
 }
Example #11
0
 public JsonSchemaNode(JsonSchema schema)
 {
     this.Schemas = new ReadOnlyCollection <JsonSchema>((IList <JsonSchema>) new JsonSchema[1]
     {
         schema
     });
     this.Properties        = new Dictionary <string, JsonSchemaNode>();
     this.PatternProperties = new Dictionary <string, JsonSchemaNode>();
     this.Items             = new List <JsonSchemaNode>();
     this.Id = JsonSchemaNode.GetId((IEnumerable <JsonSchema>) this.Schemas);
 }
        public JsonSchemaNode AddSchema(JsonSchemaNode existingNode, JsonSchema schema)
        {
            string newId;

            if (existingNode != null)
            {
                if (existingNode.Schemas.Contains(schema))
                {
                    return(existingNode);
                }

                newId = JsonSchemaNode.GetId(existingNode.Schemas.Union(new[] { schema }));
            }
            else
            {
                newId = JsonSchemaNode.GetId(new[] { schema });
            }

            if (_nodes.Contains(newId))
            {
                return(_nodes[newId]);
            }

            JsonSchemaNode currentNode = (existingNode != null)
                ? existingNode.Combine(schema)
                : new JsonSchemaNode(schema);

            _nodes.Add(currentNode);

            AddProperties(schema.Properties, currentNode.Properties);

            AddProperties(schema.PatternProperties, currentNode.PatternProperties);

            if (schema.Items != null)
            {
                for (int i = 0; i < schema.Items.Count; i++)
                {
                    AddItem(currentNode, i, schema.Items[i]);
                }
            }

            if (schema.AdditionalProperties != null)
            {
                AddAdditionalProperties(currentNode, schema.AdditionalProperties);
            }

            if (schema.Extends != null)
            {
                currentNode = AddSchema(currentNode, schema.Extends);
            }

            return(currentNode);
        }
Example #13
0
        // Token: 0x060011CB RID: 4555 RVA: 0x000626A4 File Offset: 0x000608A4
        public void AddItem(JsonSchemaNode parentNode, int index, JsonSchema schema)
        {
            JsonSchemaNode existingNode   = (parentNode.Items.Count > index) ? parentNode.Items[index] : null;
            JsonSchemaNode jsonSchemaNode = this.AddSchema(existingNode, schema);

            if (parentNode.Items.Count <= index)
            {
                parentNode.Items.Add(jsonSchemaNode);
                return;
            }
            parentNode.Items[index] = jsonSchemaNode;
        }
Example #14
0
 private JsonSchemaNode(JsonSchemaNode source, JsonSchema schema)
 {
   this.Schemas = new ReadOnlyCollection<JsonSchema>((IList<JsonSchema>) Enumerable.ToList<JsonSchema>(Enumerable.Union<JsonSchema>((IEnumerable<JsonSchema>) source.Schemas, (IEnumerable<JsonSchema>) new JsonSchema[1]
   {
     schema
   })));
   this.Properties = new Dictionary<string, JsonSchemaNode>((IDictionary<string, JsonSchemaNode>) source.Properties);
   this.PatternProperties = new Dictionary<string, JsonSchemaNode>((IDictionary<string, JsonSchemaNode>) source.PatternProperties);
   this.Items = new List<JsonSchemaNode>((IEnumerable<JsonSchemaNode>) source.Items);
   this.AdditionalProperties = source.AdditionalProperties;
   this.Id = JsonSchemaNode.GetId((IEnumerable<JsonSchema>) this.Schemas);
 }
Example #15
0
 private JsonSchemaNode(JsonSchemaNode source, JsonSchema schema)
 {
     Class6.yDnXvgqzyB5jw();
     base();
     this.Schemas              = new ReadOnlyCollection <JsonSchema>(source.Schemas.Union <JsonSchema>((IEnumerable <JsonSchema>)(new JsonSchema[] { schema })).ToList <JsonSchema>());
     this.Properties           = new Dictionary <string, JsonSchemaNode>(source.Properties);
     this.PatternProperties    = new Dictionary <string, JsonSchemaNode>(source.PatternProperties);
     this.Items                = new List <JsonSchemaNode>(source.Items);
     this.AdditionalProperties = source.AdditionalProperties;
     this.AdditionalItems      = source.AdditionalItems;
     this.Id = JsonSchemaNode.GetId(this.Schemas);
 }
 private JsonSchemaNode(JsonSchemaNode source, JsonSchema schema)
 {
     this.Schemas = new ReadOnlyCollection <JsonSchema>(Enumerable.ToList <JsonSchema>(Enumerable.Union <JsonSchema>(source.Schemas, new JsonSchema[]
     {
         schema
     })));
     this.Properties           = new Dictionary <string, JsonSchemaNode>(source.Properties);
     this.PatternProperties    = new Dictionary <string, JsonSchemaNode>(source.PatternProperties);
     this.Items                = new List <JsonSchemaNode>(source.Items);
     this.AdditionalProperties = source.AdditionalProperties;
     this.Id = JsonSchemaNode.GetId(this.Schemas);
 }
 // Token: 0x060009E5 RID: 2533
 // RVA: 0x0003EBE8 File Offset: 0x0003CDE8
 public JsonSchemaNode AddSchema(JsonSchemaNode existingNode, JsonSchema schema)
 {
     string id;
     if (existingNode != null)
     {
         if (existingNode.Schemas.Contains(schema))
         {
             return existingNode;
         }
         id = JsonSchemaNode.GetId(Enumerable.Union<JsonSchema>(existingNode.Schemas, new JsonSchema[]
         {
             schema
         }));
     }
     else
     {
         id = JsonSchemaNode.GetId(new JsonSchema[]
         {
             schema
         });
     }
     if (this._nodes.Contains(id))
     {
         return this._nodes[id];
     }
     JsonSchemaNode jsonSchemaNode = (existingNode != null) ? existingNode.Combine(schema) : new JsonSchemaNode(schema);
     this._nodes.Add(jsonSchemaNode);
     this.AddProperties(schema.Properties, jsonSchemaNode.Properties);
     this.AddProperties(schema.PatternProperties, jsonSchemaNode.PatternProperties);
     if (schema.Items != null)
     {
         for (int i = 0; i < schema.Items.Count; i++)
         {
             this.AddItem(jsonSchemaNode, i, schema.Items[i]);
         }
     }
     if (schema.AdditionalItems != null)
     {
         this.AddAdditionalItems(jsonSchemaNode, schema.AdditionalItems);
     }
     if (schema.AdditionalProperties != null)
     {
         this.AddAdditionalProperties(jsonSchemaNode, schema.AdditionalProperties);
     }
     if (schema.Extends != null)
     {
         foreach (JsonSchema current in schema.Extends)
         {
             jsonSchemaNode = this.AddSchema(jsonSchemaNode, current);
         }
     }
     return jsonSchemaNode;
 }
Example #18
0
        public void AddItem(JsonSchemaNode parentNode, int index, JsonSchema schema)
        {
            JsonSchemaNode jsonSchemaNode = this.AddSchema(parentNode.Items.Count > index ? parentNode.Items[index] : (JsonSchemaNode)null, schema);

            if (parentNode.Items.Count <= index)
            {
                parentNode.Items.Add(jsonSchemaNode);
            }
            else
            {
                parentNode.Items[index] = jsonSchemaNode;
            }
        }
Example #19
0
        public JsonSchemaNode AddSchema(JsonSchemaNode existingNode, JsonSchema schema)
        {
            string id;

            if (existingNode != null)
            {
                if (existingNode.Schemas.Contains(schema))
                {
                    return(existingNode);
                }
                JsonSchema[] second = new JsonSchema[] { schema };
                id = JsonSchemaNode.GetId(existingNode.Schemas.Union <JsonSchema>(second));
            }
            else
            {
                JsonSchema[] schemata = new JsonSchema[] { schema };
                id = JsonSchemaNode.GetId(schemata);
            }
            if (this._nodes.Contains(id))
            {
                return(this._nodes[id]);
            }
            JsonSchemaNode item = (existingNode != null) ? existingNode.Combine(schema) : new JsonSchemaNode(schema);

            this._nodes.Add(item);
            this.AddProperties(schema.Properties, item.Properties);
            this.AddProperties(schema.PatternProperties, item.PatternProperties);
            if (schema.Items != null)
            {
                for (int i = 0; i < schema.Items.Count; i++)
                {
                    this.AddItem(item, i, schema.Items[i]);
                }
            }
            if (schema.AdditionalItems != null)
            {
                this.AddAdditionalItems(item, schema.AdditionalItems);
            }
            if (schema.AdditionalProperties != null)
            {
                this.AddAdditionalProperties(item, schema.AdditionalProperties);
            }
            if (schema.Extends != null)
            {
                foreach (JsonSchema schema2 in schema.Extends)
                {
                    item = this.AddSchema(item, schema2);
                }
            }
            return(item);
        }
Example #20
0
        public void AddItem(JsonSchemaNode parentNode, int index, JsonSchema schema)
        {
            JsonSchemaNode existingNode = (parentNode.Items.Count > index) ? parentNode.Items[index] : null;
            JsonSchemaNode item         = this.AddSchema(existingNode, schema);

            if (parentNode.Items.Count <= index)
            {
                parentNode.Items.Add(item);
            }
            else
            {
                parentNode.Items[index] = item;
            }
        }
Example #21
0
        private JsonSchemaModel BuildNodeModel(JsonSchemaNode node)
        {
            JsonSchemaModel model;

            if (_nodeModels.TryGetValue(node, out model))
            {
                return(model);
            }

            model             = JsonSchemaModel.Create(node.Schemas);
            _nodeModels[node] = model;

            foreach (KeyValuePair <string, JsonSchemaNode> property in node.Properties)
            {
                if (model.Properties == null)
                {
                    model.Properties = new Dictionary <string, JsonSchemaModel>();
                }

                model.Properties[property.Key] = BuildNodeModel(property.Value);
            }
            foreach (KeyValuePair <string, JsonSchemaNode> property in node.PatternProperties)
            {
                if (model.PatternProperties == null)
                {
                    model.PatternProperties = new Dictionary <string, JsonSchemaModel>();
                }

                model.PatternProperties[property.Key] = BuildNodeModel(property.Value);
            }
            foreach (JsonSchemaNode t in node.Items)
            {
                if (model.Items == null)
                {
                    model.Items = new List <JsonSchemaModel>();
                }

                model.Items.Add(BuildNodeModel(t));
            }
            if (node.AdditionalProperties != null)
            {
                model.AdditionalProperties = BuildNodeModel(node.AdditionalProperties);
            }
            if (node.AdditionalItems != null)
            {
                model.AdditionalItems = BuildNodeModel(node.AdditionalItems);
            }

            return(model);
        }
Example #22
0
        public void AddItem(JsonSchemaNode parentNode, int index, JsonSchema schema)
        {
            JsonSchemaNode existingNode   = (parentNode.Items.Count <= index) ? null : parentNode.Items[index];
            JsonSchemaNode jsonSchemaNode = AddSchema(existingNode, schema);

            if (parentNode.Items.Count <= index)
            {
                parentNode.Items.Add(jsonSchemaNode);
            }
            else
            {
                parentNode.Items[index] = jsonSchemaNode;
            }
        }
        public void AddItem(JsonSchemaNode parentNode, int index, JsonSchema schema)
        {
            JsonSchemaNode existingNode   = (parentNode.Items.get_Count() <= index) ? null : parentNode.Items.get_Item(index);
            JsonSchemaNode jsonSchemaNode = this.AddSchema(existingNode, schema);

            if (parentNode.Items.get_Count() <= index)
            {
                parentNode.Items.Add(jsonSchemaNode);
            }
            else
            {
                parentNode.Items.set_Item(index, jsonSchemaNode);
            }
        }
Example #24
0
        public JsonSchemaNode AddSchema(JsonSchemaNode existingNode, JsonSchema schema)
        {
            string id;

            if (existingNode == null)
            {
                id = JsonSchemaNode.GetId((IEnumerable <JsonSchema>)(new JsonSchema[] { schema }));
            }
            else
            {
                if (existingNode.Schemas.Contains(schema))
                {
                    return(existingNode);
                }
                id = JsonSchemaNode.GetId(existingNode.Schemas.Union <JsonSchema>((IEnumerable <JsonSchema>)(new JsonSchema[] { schema })));
            }
            if (this._nodes.Contains(id))
            {
                return(this._nodes[id]);
            }
            JsonSchemaNode jsonSchemaNode = (existingNode != null ? existingNode.Combine(schema) : new JsonSchemaNode(schema));

            this._nodes.Add(jsonSchemaNode);
            this.AddProperties(schema.Properties, jsonSchemaNode.Properties);
            this.AddProperties(schema.PatternProperties, jsonSchemaNode.PatternProperties);
            if (schema.Items != null)
            {
                for (int i = 0; i < schema.Items.Count; i++)
                {
                    this.AddItem(jsonSchemaNode, i, schema.Items[i]);
                }
            }
            if (schema.AdditionalItems != null)
            {
                this.AddAdditionalItems(jsonSchemaNode, schema.AdditionalItems);
            }
            if (schema.AdditionalProperties != null)
            {
                this.AddAdditionalProperties(jsonSchemaNode, schema.AdditionalProperties);
            }
            if (schema.Extends != null)
            {
                foreach (JsonSchema extend in schema.Extends)
                {
                    jsonSchemaNode = this.AddSchema(jsonSchemaNode, extend);
                }
            }
            return(jsonSchemaNode);
        }
        private JsonSchemaModel BuildNodeModel(JsonSchemaNode node)
        {
            JsonSchemaModel jsonSchemaModel;

            if (this._nodeModels.TryGetValue(node, ref jsonSchemaModel))
            {
                return(jsonSchemaModel);
            }
            jsonSchemaModel = JsonSchemaModel.Create(node.Schemas);
            this._nodeModels.set_Item(node, jsonSchemaModel);
            using (Dictionary <string, JsonSchemaNode> .Enumerator enumerator = node.Properties.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    KeyValuePair <string, JsonSchemaNode> current = enumerator.get_Current();
                    if (jsonSchemaModel.Properties == null)
                    {
                        jsonSchemaModel.Properties = new Dictionary <string, JsonSchemaModel>();
                    }
                    jsonSchemaModel.Properties.set_Item(current.get_Key(), this.BuildNodeModel(current.get_Value()));
                }
            }
            using (Dictionary <string, JsonSchemaNode> .Enumerator enumerator2 = node.PatternProperties.GetEnumerator())
            {
                while (enumerator2.MoveNext())
                {
                    KeyValuePair <string, JsonSchemaNode> current2 = enumerator2.get_Current();
                    if (jsonSchemaModel.PatternProperties == null)
                    {
                        jsonSchemaModel.PatternProperties = new Dictionary <string, JsonSchemaModel>();
                    }
                    jsonSchemaModel.PatternProperties.set_Item(current2.get_Key(), this.BuildNodeModel(current2.get_Value()));
                }
            }
            for (int i = 0; i < node.Items.get_Count(); i++)
            {
                if (jsonSchemaModel.Items == null)
                {
                    jsonSchemaModel.Items = new List <JsonSchemaModel>();
                }
                jsonSchemaModel.Items.Add(this.BuildNodeModel(node.Items.get_Item(i)));
            }
            if (node.AdditionalProperties != null)
            {
                jsonSchemaModel.AdditionalProperties = this.BuildNodeModel(node.AdditionalProperties);
            }
            return(jsonSchemaModel);
        }
Example #26
0
        public JsonSchemaNode AddSchema(JsonSchemaNode existingNode, JsonSchema schema)
        {
            string id;

            if (existingNode != null)
            {
                if (existingNode.Schemas.Contains(schema))
                {
                    return(existingNode);
                }
                id = JsonSchemaNode.GetId(existingNode.Schemas.Union(new JsonSchema[1]
                {
                    schema
                }));
            }
            else
            {
                id = JsonSchemaNode.GetId(new JsonSchema[1]
                {
                    schema
                });
            }
            if (_nodes.Contains(id))
            {
                return(_nodes[id]);
            }
            JsonSchemaNode jsonSchemaNode = (existingNode == null) ? new JsonSchemaNode(schema) : existingNode.Combine(schema);

            _nodes.Add(jsonSchemaNode);
            AddProperties(schema.Properties, jsonSchemaNode.Properties);
            AddProperties(schema.PatternProperties, jsonSchemaNode.PatternProperties);
            if (schema.Items != null)
            {
                for (int i = 0; i < schema.Items.Count; i++)
                {
                    AddItem(jsonSchemaNode, i, schema.Items[i]);
                }
            }
            if (schema.AdditionalProperties != null)
            {
                AddAdditionalProperties(jsonSchemaNode, schema.AdditionalProperties);
            }
            if (schema.Extends != null)
            {
                jsonSchemaNode = AddSchema(jsonSchemaNode, schema.Extends);
            }
            return(jsonSchemaNode);
        }
        public JsonSchemaNode AddSchema(JsonSchemaNode existingNode, JsonSchema schema)
        {
            string id;

            if (existingNode != null)
            {
                if (existingNode.Schemas.Contains(schema))
                {
                    return(existingNode);
                }
                id = JsonSchemaNode.GetId(Enumerable.Union <JsonSchema>(existingNode.Schemas, new JsonSchema[]
                {
                    schema
                }));
            }
            else
            {
                id = JsonSchemaNode.GetId(new JsonSchema[]
                {
                    schema
                });
            }
            if (this._nodes.Contains(id))
            {
                return(this._nodes.get_Item(id));
            }
            JsonSchemaNode jsonSchemaNode = (existingNode == null) ? new JsonSchemaNode(schema) : existingNode.Combine(schema);

            this._nodes.Add(jsonSchemaNode);
            this.AddProperties(schema.Properties, jsonSchemaNode.Properties);
            this.AddProperties(schema.PatternProperties, jsonSchemaNode.PatternProperties);
            if (schema.Items != null)
            {
                for (int i = 0; i < schema.Items.get_Count(); i++)
                {
                    this.AddItem(jsonSchemaNode, i, schema.Items.get_Item(i));
                }
            }
            if (schema.AdditionalProperties != null)
            {
                this.AddAdditionalProperties(jsonSchemaNode, schema.AdditionalProperties);
            }
            if (schema.Extends != null)
            {
                jsonSchemaNode = this.AddSchema(jsonSchemaNode, schema.Extends);
            }
            return(jsonSchemaNode);
        }
Example #28
0
        public JsonSchemaNode AddSchema(JsonSchemaNode existingNode, JsonSchema schema)
        {
            string id;

            if (existingNode != null)
            {
                if (existingNode.Schemas.Contains(schema))
                {
                    return(existingNode);
                }
                id = JsonSchemaNode.GetId(Enumerable.Union <JsonSchema>((IEnumerable <JsonSchema>)existingNode.Schemas, (IEnumerable <JsonSchema>) new JsonSchema[1]
                {
                    schema
                }));
            }
            else
            {
                id = JsonSchemaNode.GetId((IEnumerable <JsonSchema>) new JsonSchema[1]
                {
                    schema
                });
            }
            if (this._nodes.Contains(id))
            {
                return(this._nodes[id]);
            }
            JsonSchemaNode jsonSchemaNode = existingNode != null?existingNode.Combine(schema) : new JsonSchemaNode(schema);

            this._nodes.Add(jsonSchemaNode);
            this.AddProperties(schema.Properties, (IDictionary <string, JsonSchemaNode>)jsonSchemaNode.Properties);
            this.AddProperties(schema.PatternProperties, (IDictionary <string, JsonSchemaNode>)jsonSchemaNode.PatternProperties);
            if (schema.Items != null)
            {
                for (int index = 0; index < schema.Items.Count; ++index)
                {
                    this.AddItem(jsonSchemaNode, index, schema.Items[index]);
                }
            }
            if (schema.AdditionalProperties != null)
            {
                this.AddAdditionalProperties(jsonSchemaNode, schema.AdditionalProperties);
            }
            if (schema.Extends != null)
            {
                jsonSchemaNode = this.AddSchema(jsonSchemaNode, schema.Extends);
            }
            return(jsonSchemaNode);
        }
    public JsonSchemaNode AddSchema(JsonSchemaNode existingNode, JsonSchema schema)
    {
      string newId;
      if (existingNode != null)
      {
        if (existingNode.Schemas.Contains(schema))
          return existingNode;

        newId = JsonSchemaNode.GetId(existingNode.Schemas.Union(new[] { schema }));
      }
      else
      {
        newId = JsonSchemaNode.GetId(new[] { schema });
      }

      if (_nodes.Contains(newId))
        return _nodes[newId];

      JsonSchemaNode currentNode = (existingNode != null)
        ? existingNode.Combine(schema)
        : new JsonSchemaNode(schema);

      _nodes.Add(currentNode);

      if (schema.Properties != null)
      {
        foreach (KeyValuePair<string, JsonSchema> property in schema.Properties)
        {
          AddProperty(currentNode, property.Key, property.Value);
        }
      }

      if (schema.Items != null)
      {
        for (int i = 0; i < schema.Items.Count; i++)
        {
          AddItem(currentNode, i, schema.Items[i]);
        }
      }

      if (schema.AdditionalProperties != null)
        AddAdditionalProperties(currentNode, schema.AdditionalProperties);

      if (schema.Extends != null)
        currentNode = AddSchema(currentNode, schema.Extends);

      return currentNode;
    }
        public void AddItem(JsonSchemaNode parentNode, int index, JsonSchema schema)
        {
            JsonSchemaNode existingItemNode =
                (parentNode.Items.Count > index) ? parentNode.Items[index] : null;

            JsonSchemaNode newItemNode = AddSchema(existingItemNode, schema);

            if (!(parentNode.Items.Count > index))
            {
                parentNode.Items.Add(newItemNode);
            }
            else
            {
                parentNode.Items[index] = newItemNode;
            }
        }
        public void AddItem(JsonSchemaNode parentNode, int index, JsonSchema schema)
        {
            JsonSchemaNode existingItemNode = (parentNode.Items.Count > index)
                                  ? parentNode.Items[index]
                                  : null;

              JsonSchemaNode newItemNode = AddSchema(existingItemNode, schema);

              if (!(parentNode.Items.Count > index))
              {
            parentNode.Items.Add(newItemNode);
              }
              else
              {
            parentNode.Items[index] = newItemNode;
              }
        }
Example #32
0
        // Token: 0x060011CE RID: 4558 RVA: 0x00062740 File Offset: 0x00060940
        private JsonSchemaModel BuildNodeModel(JsonSchemaNode node)
        {
            JsonSchemaModel jsonSchemaModel;

            if (this._nodeModels.TryGetValue(node, out jsonSchemaModel))
            {
                return(jsonSchemaModel);
            }
            jsonSchemaModel        = JsonSchemaModel.Create(node.Schemas);
            this._nodeModels[node] = jsonSchemaModel;
            foreach (KeyValuePair <string, JsonSchemaNode> keyValuePair in node.Properties)
            {
                if (jsonSchemaModel.Properties == null)
                {
                    jsonSchemaModel.Properties = new Dictionary <string, JsonSchemaModel>();
                }
                jsonSchemaModel.Properties[keyValuePair.Key] = this.BuildNodeModel(keyValuePair.Value);
            }
            foreach (KeyValuePair <string, JsonSchemaNode> keyValuePair2 in node.PatternProperties)
            {
                if (jsonSchemaModel.PatternProperties == null)
                {
                    jsonSchemaModel.PatternProperties = new Dictionary <string, JsonSchemaModel>();
                }
                jsonSchemaModel.PatternProperties[keyValuePair2.Key] = this.BuildNodeModel(keyValuePair2.Value);
            }
            foreach (JsonSchemaNode node2 in node.Items)
            {
                if (jsonSchemaModel.Items == null)
                {
                    jsonSchemaModel.Items = new List <JsonSchemaModel>();
                }
                jsonSchemaModel.Items.Add(this.BuildNodeModel(node2));
            }
            if (node.AdditionalProperties != null)
            {
                jsonSchemaModel.AdditionalProperties = this.BuildNodeModel(node.AdditionalProperties);
            }
            if (node.AdditionalItems != null)
            {
                jsonSchemaModel.AdditionalItems = this.BuildNodeModel(node.AdditionalItems);
            }
            return(jsonSchemaModel);
        }
Example #33
0
        private JsonSchemaModel BuildNodeModel(JsonSchemaNode node)
        {
            JsonSchemaModel strs;

            if (this._nodeModels.TryGetValue(node, out strs))
            {
                return(strs);
            }
            strs = JsonSchemaModel.Create(node.Schemas);
            this._nodeModels[node] = strs;
            foreach (KeyValuePair <string, JsonSchemaNode> property in node.Properties)
            {
                if (strs.Properties == null)
                {
                    strs.Properties = new Dictionary <string, JsonSchemaModel>();
                }
                strs.Properties[property.Key] = this.BuildNodeModel(property.Value);
            }
            foreach (KeyValuePair <string, JsonSchemaNode> patternProperty in node.PatternProperties)
            {
                if (strs.PatternProperties == null)
                {
                    strs.PatternProperties = new Dictionary <string, JsonSchemaModel>();
                }
                strs.PatternProperties[patternProperty.Key] = this.BuildNodeModel(patternProperty.Value);
            }
            foreach (JsonSchemaNode item in node.Items)
            {
                if (strs.Items == null)
                {
                    strs.Items = new List <JsonSchemaModel>();
                }
                strs.Items.Add(this.BuildNodeModel(item));
            }
            if (node.AdditionalProperties != null)
            {
                strs.AdditionalProperties = this.BuildNodeModel(node.AdditionalProperties);
            }
            if (node.AdditionalItems != null)
            {
                strs.AdditionalItems = this.BuildNodeModel(node.AdditionalItems);
            }
            return(strs);
        }
Example #34
0
        public void AddItem(JsonSchemaNode parentNode, int index, JsonSchema schema)
        {
            JsonSchemaNode item;

            if (parentNode.Items.Count > index)
            {
                item = parentNode.Items[index];
            }
            else
            {
                item = null;
            }
            JsonSchemaNode jsonSchemaNode = this.AddSchema(item, schema);

            if (parentNode.Items.Count <= index)
            {
                parentNode.Items.Add(jsonSchemaNode);
                return;
            }
            parentNode.Items[index] = jsonSchemaNode;
        }
Example #35
0
 private JsonSchemaModel BuildNodeModel(JsonSchemaNode node)
 {
     if (_nodeModels.TryGetValue(node, out JsonSchemaModel value))
     {
         return(value);
     }
     value             = JsonSchemaModel.Create(node.Schemas);
     _nodeModels[node] = value;
     foreach (KeyValuePair <string, JsonSchemaNode> property in node.Properties)
     {
         if (value.Properties == null)
         {
             value.Properties = new Dictionary <string, JsonSchemaModel>();
         }
         value.Properties[property.Key] = BuildNodeModel(property.Value);
     }
     foreach (KeyValuePair <string, JsonSchemaNode> patternProperty in node.PatternProperties)
     {
         if (value.PatternProperties == null)
         {
             value.PatternProperties = new Dictionary <string, JsonSchemaModel>();
         }
         value.PatternProperties[patternProperty.Key] = BuildNodeModel(patternProperty.Value);
     }
     for (int i = 0; i < node.Items.Count; i++)
     {
         if (value.Items == null)
         {
             value.Items = new List <JsonSchemaModel>();
         }
         value.Items.Add(BuildNodeModel(node.Items[i]));
     }
     if (node.AdditionalProperties != null)
     {
         value.AdditionalProperties = BuildNodeModel(node.AdditionalProperties);
     }
     return(value);
 }
Example #36
0
 private JsonSchemaModel BuildNodeModel(JsonSchemaNode node)
 {
   JsonSchemaModel jsonSchemaModel1;
   if (this._nodeModels.TryGetValue(node, out jsonSchemaModel1))
     return jsonSchemaModel1;
   JsonSchemaModel jsonSchemaModel2 = JsonSchemaModel.Create((IList<JsonSchema>) node.Schemas);
   this._nodeModels[node] = jsonSchemaModel2;
   foreach (KeyValuePair<string, JsonSchemaNode> keyValuePair in node.Properties)
   {
     if (jsonSchemaModel2.Properties == null)
       jsonSchemaModel2.Properties = (IDictionary<string, JsonSchemaModel>) new Dictionary<string, JsonSchemaModel>();
     jsonSchemaModel2.Properties[keyValuePair.Key] = this.BuildNodeModel(keyValuePair.Value);
   }
   foreach (KeyValuePair<string, JsonSchemaNode> keyValuePair in node.PatternProperties)
   {
     if (jsonSchemaModel2.PatternProperties == null)
       jsonSchemaModel2.PatternProperties = (IDictionary<string, JsonSchemaModel>) new Dictionary<string, JsonSchemaModel>();
     jsonSchemaModel2.PatternProperties[keyValuePair.Key] = this.BuildNodeModel(keyValuePair.Value);
   }
   foreach (JsonSchemaNode node1 in node.Items)
   {
     if (jsonSchemaModel2.Items == null)
       jsonSchemaModel2.Items = (IList<JsonSchemaModel>) new List<JsonSchemaModel>();
     jsonSchemaModel2.Items.Add(this.BuildNodeModel(node1));
   }
   if (node.AdditionalProperties != null)
     jsonSchemaModel2.AdditionalProperties = this.BuildNodeModel(node.AdditionalProperties);
   return jsonSchemaModel2;
 }
Example #37
0
        private JsonSchemaModel BuildNodeModel(JsonSchemaNode node)
        {
            JsonSchemaModel model;
            if (_nodeModels.TryGetValue(node, out model))
                return model;

            model = JsonSchemaModel.Create(node.Schemas);
            _nodeModels[node] = model;

            foreach (KeyValuePair<string, JsonSchemaNode> property in node.Properties)
            {
                if (model.Properties == null)
                    model.Properties = new Dictionary<string, JsonSchemaModel>();

                model.Properties[property.Key] = BuildNodeModel(property.Value);
            }
            foreach (KeyValuePair<string, JsonSchemaNode> property in node.PatternProperties)
            {
                if (model.PatternProperties == null)
                    model.PatternProperties = new Dictionary<string, JsonSchemaModel>();

                model.PatternProperties[property.Key] = BuildNodeModel(property.Value);
            }
            foreach (JsonSchemaNode t in node.Items)
            {
                if (model.Items == null)
                    model.Items = new List<JsonSchemaModel>();

                model.Items.Add(BuildNodeModel(t));
            }
            if (node.AdditionalProperties != null)
                model.AdditionalProperties = BuildNodeModel(node.AdditionalProperties);
            if (node.AdditionalItems != null)
                model.AdditionalItems = BuildNodeModel(node.AdditionalItems);

            return model;
        }
Example #38
0
 public void AddAdditionalItems(JsonSchemaNode parentNode, JsonSchema schema)
 {
     parentNode.AdditionalItems = AddSchema(parentNode.AdditionalItems, schema);
 }
Example #39
0
 public void AddAdditionalProperties(JsonSchemaNode parentNode, JsonSchema schema)
 {
     parentNode.AdditionalProperties = AddSchema(parentNode.AdditionalProperties, schema);
 }
Example #40
0
 public void AddAdditionalItems(JsonSchemaNode parentNode, JsonSchema schema)
 {
     parentNode.AdditionalItems = AddSchema(parentNode.AdditionalItems, schema);
 }
Example #41
0
 public void AddAdditionalProperties(JsonSchemaNode parentNode, JsonSchema schema)
 {
     parentNode.AdditionalProperties = AddSchema(parentNode.AdditionalProperties, schema);
 }
 // Token: 0x060009EB RID: 2539
 // RVA: 0x0003EE2C File Offset: 0x0003D02C
 private JsonSchemaModel BuildNodeModel(JsonSchemaNode node)
 {
     JsonSchemaModel jsonSchemaModel;
     if (this._nodeModels.TryGetValue(node, out jsonSchemaModel))
     {
         return jsonSchemaModel;
     }
     jsonSchemaModel = JsonSchemaModel.Create(node.Schemas);
     this._nodeModels[node] = jsonSchemaModel;
     foreach (KeyValuePair<string, JsonSchemaNode> current in node.Properties)
     {
         if (jsonSchemaModel.Properties == null)
         {
             jsonSchemaModel.Properties = new Dictionary<string, JsonSchemaModel>();
         }
         jsonSchemaModel.Properties[current.Key] = this.BuildNodeModel(current.Value);
     }
     foreach (KeyValuePair<string, JsonSchemaNode> current2 in node.PatternProperties)
     {
         if (jsonSchemaModel.PatternProperties == null)
         {
             jsonSchemaModel.PatternProperties = new Dictionary<string, JsonSchemaModel>();
         }
         jsonSchemaModel.PatternProperties[current2.Key] = this.BuildNodeModel(current2.Value);
     }
     foreach (JsonSchemaNode current3 in node.Items)
     {
         if (jsonSchemaModel.Items == null)
         {
             jsonSchemaModel.Items = new List<JsonSchemaModel>();
         }
         jsonSchemaModel.Items.Add(this.BuildNodeModel(current3));
     }
     if (node.AdditionalProperties != null)
     {
         jsonSchemaModel.AdditionalProperties = this.BuildNodeModel(node.AdditionalProperties);
     }
     if (node.AdditionalItems != null)
     {
         jsonSchemaModel.AdditionalItems = this.BuildNodeModel(node.AdditionalItems);
     }
     return jsonSchemaModel;
 }