本文整理汇总了C#中Newtonsoft.Json.Schema.JsonSchemaNode类的典型用法代码示例。如果您正苦于以下问题:C# JsonSchemaNode类的具体用法?C# JsonSchemaNode怎么用?C# JsonSchemaNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsonSchemaNode类属于Newtonsoft.Json.Schema命名空间,在下文中一共展示了JsonSchemaNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddSchema
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;
}
示例2: Build
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);
}
示例3: AddSchema
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;
}
示例4: AddProperty
public void AddProperty(JsonSchemaNode parentNode, string propertyName, JsonSchema schema)
{
JsonSchemaNode propertyNode;
parentNode.Properties.TryGetValue(propertyName, out propertyNode);
parentNode.Properties[propertyName] = AddSchema(propertyNode, schema);
}
示例5: AddItem
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;
}
示例6: 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);
}
示例7: Build
public JsonSchemaModel Build(JsonSchema schema)
{
_nodes = new JsonSchemaNodeCollection();
_node = AddSchema(null, schema);
_nodeModels = new Dictionary<JsonSchemaNode, JsonSchemaModel>();
JsonSchemaModel model = BuildNodeModel(_node);
return model;
}
示例8: AddItem
// 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;
}
示例9: JsonSchemaNode
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);
}
示例10: AddSchema
// 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;
}
示例11: AddSchema
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;
}
示例12: AddItem
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;
}
}
示例13: AddAdditionalItems
public void AddAdditionalItems(JsonSchemaNode parentNode, JsonSchema schema)
{
parentNode.AdditionalItems = AddSchema(parentNode.AdditionalItems, schema);
}
示例14: AddAdditionalProperties
public void AddAdditionalProperties(JsonSchemaNode parentNode, JsonSchema schema)
{
parentNode.AdditionalProperties = AddSchema(parentNode.AdditionalProperties, schema);
}
示例15: BuildNodeModel
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;
}