Create() public static method

public static Create ( IList schemata ) : JsonSchemaModel
schemata IList
return JsonSchemaModel
    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);
      }
      for (int i = 0; i < node.Items.Count; i++)
      {
        if (model.Items == null)
          model.Items = new List<JsonSchemaModel>();

        model.Items.Add(BuildNodeModel(node.Items[i]));
      }
      if (node.AdditionalProperties != null)
        model.AdditionalProperties = BuildNodeModel(node.AdditionalProperties);

      return model;
    }
Example #2
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);
        }
        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 #4
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 #5
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 #6
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);
 }