Пример #1
0
        /// <summary>Adds a schema to type mapping.</summary>
        /// <param name="type">The type.</param>
        /// <param name="isIntegerEnumeration">Specifies whether the type is an integer enum.</param>
        /// <param name="schema">The schema.</param>
        /// <exception cref="InvalidOperationException">Added schema is not a JsonSchema4 instance.</exception>
        public virtual void AddSchema(Type type, bool isIntegerEnumeration, JsonSchema schema)
        {
            if (schema.GetType() != typeof(JsonSchema))
            {
                throw new InvalidOperationException("Added schema is not a JsonSchema4 instance.");
            }

            if (schema != RootObject)
            {
                AppendSchema(schema, _settings.SchemaNameGenerator.Generate(type));
            }

            _mappings.Add(GetTypeKey(type, isIntegerEnumeration), schema);
        }