Esempio n. 1
0
        public static JsonSchema GetSchema(TextReader reader)
        {
            JsonDocument document = GetDocument(reader);
            bool isValid = JsonSchema.Draft04.IsValid(document.Root);

            if (isValid == false)
                throw new JsonSchemaException("The schema is not valid against draft-04.");

            JsonSchemaReader schemaReader = new JsonSchemaReader(document);
            JsonSchema schema = schemaReader.Load();

            return schema;
        }
Esempio n. 2
0
        private static JsonSchema GetSchema(string name)
        {
            Assembly assembly = typeof(JsonSchema).Assembly;
            string fullName = $"Resources.{name}";

            using (Stream stream = assembly.GetManifestResourceStream(typeof(JsonSchema), fullName))
            using (TextReader reader = new StreamReader(stream))
            {
                var jsonReader = new JsonReader(reader);
                var documentReader = new JsonDocumentReader(jsonReader);
                var document = documentReader.Load();
                var schemaReader = new JsonSchemaReader(document);

                return schemaReader.Load();
            }
        }