Пример #1
0
        private void WriteType(string propertyName, JsonWriter writer, JsonSchemaType type)
        {
            IList <JsonSchemaType> types;

            if (System.Enum.IsDefined(typeof(JsonSchemaType), type))
            {
                types = new List <JsonSchemaType> {
                    type
                }
            }
            ;
            else
            {
                types = EnumUtils.GetFlagsValues(type).Where(v => v != JsonSchemaType.None).ToList();
            }

            if (types.Count == 0)
            {
                return;
            }

            writer.WritePropertyName(propertyName);

            if (types.Count == 1)
            {
                writer.WriteValue(JsonSchemaBuilder.MapType(types[0]));
                return;
            }

            writer.WriteStartArray();
            foreach (JsonSchemaType jsonSchemaType in types)
            {
                writer.WriteValue(JsonSchemaBuilder.MapType(jsonSchemaType));
            }
            writer.WriteEndArray();
        }