Пример #1
0
        /// <summary>
        /// Loads a <see cref="JSchema"/> from a <see cref="JsonReader"/> using the given <see cref="JSchemaResolver"/>.
        /// </summary>
        /// <param name="reader">The <see cref="JsonReader"/> containing the JSON Schema to load.</param>
        /// <param name="settings">The <see cref="JSchemaReaderSettings"/> used to load the schema.</param>
        /// <returns>The <see cref="JSchema"/> object representing the JSON Schema.</returns>
        public static JSchema Load(JsonReader reader, JSchemaReaderSettings settings)
        {
            ValidationUtils.ArgumentNotNull(reader, "reader");
            ValidationUtils.ArgumentNotNull(settings, "settings");

            JSchemaReader schemaReader = new JSchemaReader(settings);

            return(schemaReader.ReadRoot(reader));
        }
Пример #2
0
        /// <summary>
        /// Load a <see cref="JSchema"/> from a string that contains schema JSON using the given <see cref="JSchemaReaderSettings"/>.
        /// </summary>
        /// <param name="json">The JSON.</param>
        /// <param name="settings">The <see cref="JSchemaReaderSettings"/> used to load the schema.</param>
        /// <returns>A <see cref="JSchema"/> populated from the string that contains JSON.</returns>
        public static JSchema Parse(string json, JSchemaReaderSettings settings)
        {
            ValidationUtils.ArgumentNotNull(json, "json");
            ValidationUtils.ArgumentNotNull(settings, "settings");

            using (JsonReader reader = new JsonTextReader(new StringReader(json)))
            {
                return(Load(reader, settings));
            }
        }
Пример #3
0
        /// <summary>
        /// Load a <see cref="JSchema"/> from a string that contains schema JSON using the given <see cref="JSchemaReaderSettings"/>.
        /// </summary>
        /// <param name="json">The JSON.</param>
        /// <param name="settings">The <see cref="JSchemaReaderSettings"/> used to load the schema.</param>
        /// <returns>A <see cref="JSchema"/> populated from the string that contains JSON.</returns>
        public static JSchema Parse(string json, JSchemaReaderSettings settings)
        {
            ValidationUtils.ArgumentNotNull(json, nameof(json));
            ValidationUtils.ArgumentNotNull(settings, nameof(settings));

            using (JsonReader reader = new JsonTextReader(new StringReader(json)))
            {
                JSchema s = Load(reader, settings);

                // read to make sure there isn't additional content
                reader.Read();

                return(s);
            }
        }
Пример #4
0
        /// <summary>
        /// Load a <see cref="JSchema"/> from a string that contains schema JSON using the given <see cref="JSchemaReaderSettings"/>.
        /// </summary>
        /// <param name="json">The JSON.</param>
        /// <param name="settings">The <see cref="JSchemaReaderSettings"/> used to load the schema.</param>
        /// <returns>A <see cref="JSchema"/> populated from the string that contains JSON.</returns>
        public static JSchema Parse(string json, JSchemaReaderSettings settings)
        {
            ValidationUtils.ArgumentNotNull(json, "json");
            ValidationUtils.ArgumentNotNull(settings, "settings");

            using (JsonReader reader = new JsonTextReader(new StringReader(json)))
            {
                return Load(reader, settings);
            }
        }
Пример #5
0
        /// <summary>
        /// Loads a <see cref="JSchema"/> from a <see cref="JsonReader"/> using the given <see cref="JSchemaResolver"/>.
        /// </summary>
        /// <param name="reader">The <see cref="JsonReader"/> containing the JSON Schema to load.</param>
        /// <param name="settings">The <see cref="JSchemaReaderSettings"/> used to load the schema.</param>
        /// <returns>The <see cref="JSchema"/> object representing the JSON Schema.</returns>
        public static JSchema Load(JsonReader reader, JSchemaReaderSettings settings)
        {
            ValidationUtils.ArgumentNotNull(reader, "reader");
            ValidationUtils.ArgumentNotNull(settings, "settings");

            JSchemaReader schemaReader = new JSchemaReader(settings);
            return schemaReader.ReadRoot(reader);
        }