using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; namespace DPumpHydr.WinFrmUI.WenSkin.Json.Schema { [Obsolete("JSON Schema validation has been moved to its own package. See http://www.newtonsoft.com/jsonschema for more details.")] internal class JsonSchemaNode { public string Id { get; private set; } public ReadOnlyCollection Schemas { get; private set; } public Dictionary Properties { get; private set; } public Dictionary PatternProperties { get; private set; } public List Items { get; private set; } public JsonSchemaNode AdditionalProperties { get; set; } public JsonSchemaNode AdditionalItems { get; set; } public JsonSchemaNode(JsonSchema schema) { Schemas = new ReadOnlyCollection(new JsonSchema[1] { schema }); Properties = new Dictionary(); PatternProperties = new Dictionary(); Items = new List(); Id = GetId(Schemas); } private JsonSchemaNode(JsonSchemaNode source, JsonSchema schema) { Schemas = new ReadOnlyCollection(source.Schemas.Union(new JsonSchema[1] { schema }).ToList()); Properties = new Dictionary(source.Properties); PatternProperties = new Dictionary(source.PatternProperties); Items = new List(source.Items); AdditionalProperties = source.AdditionalProperties; AdditionalItems = source.AdditionalItems; Id = GetId(Schemas); } public JsonSchemaNode Combine(JsonSchema schema) { return new JsonSchemaNode(this, schema); } public static string GetId(IEnumerable schemata) { return string.Join("-", schemata.Select((JsonSchema s) => s.InternalId).OrderBy((string id) => id, StringComparer.Ordinal).ToArray()); } } }