Пример #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, JsonSchema4 schema)
        {
            if (schema.GetType() != typeof(JsonSchema4))
            {
                throw new InvalidOperationException("Added schema is not a JsonSchema4 instance.");
            }

            AppendSchema(schema, _settings.SchemaNameGenerator.Generate(type));
            _mappings.Add(GetKey(type, isIntegerEnumeration), schema);
        }
Пример #2
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 void AddSchema(Type type, bool isIntegerEnumeration, JsonSchema4 schema)
        {
            if (schema.GetType() != typeof(JsonSchema4))
                throw new InvalidOperationException("Added schema is not a JsonSchema4 instance.");

            //#if DEBUG
            //            // TODO: (low-prio) Check code so that type names are unique
            //            if (Schemes.Any(s => s.TypeName == schema.TypeName))
            //                throw new InvalidOperationException("The type name '"+ schema.TypeName + "' is already registered in the schema resolver.");
            //#endif

            _mappings.Add(GetKey(type, isIntegerEnumeration), schema);
        }
Пример #3
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 void AddSchema(Type type, bool isIntegerEnumeration, JsonSchema4 schema)
        {
            if (schema.GetType() != typeof(JsonSchema4))
            {
                throw new InvalidOperationException("Added schema is not a JsonSchema4 instance.");
            }

//#if DEBUG
//            // TODO: (low-prio) Check code so that type names are unique
//            if (Schemas.Any(s => s.TypeName == schema.TypeName))
//                throw new InvalidOperationException("The type name '"+ schema.TypeName + "' is already registered in the schema resolver.");
//#endif

            _mappings.Add(GetKey(type, isIntegerEnumeration), schema);
        }
Пример #4
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 void AddSchema(Type type, bool isIntegerEnumeration, JsonSchema4 schema)
        {
            if (schema.GetType() != typeof(JsonSchema4))
            {
                throw new InvalidOperationException("Added schema is not a JsonSchema4 instance.");
            }

            // TODO: Check this
//#if DEBUG
//            if (Schemes.Any(s => s.TypeName == schema.TypeName))
//                throw new InvalidOperationException("TypeName already exists.");
//#endif

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