Newtonsoft.Json.Schema.JsonSchemaBuilder.MapType C# (CSharp) Method

MapType() static private method

static private MapType ( string type ) : JsonSchemaType
type string
return JsonSchemaType
    internal static JsonSchemaType MapType(string type)
    {
      JsonSchemaType mappedType;
      if (!JsonSchemaConstants.JsonSchemaTypeMapping.TryGetValue(type, out mappedType))
        throw new Exception("Invalid JSON schema type: {0}".FormatWith(CultureInfo.InvariantCulture, type));

      return mappedType;
    }

Same methods

JsonSchemaBuilder::MapType ( JsonSchemaType type ) : string

Usage Example

Esempio n. 1
0
        private void WriteType(string propertyName, JsonWriter writer, JsonSchemaType type)
        {
            if (Enum.IsDefined(typeof(JsonSchemaType), type))
            {
                writer.WritePropertyName(propertyName);
                writer.WriteValue(JsonSchemaBuilder.MapType(type));
                return;
            }
            IEnumerator <JsonSchemaType> enumerator = (
                from v in EnumUtils.GetFlagsValues <JsonSchemaType>(type)
                where v != JsonSchemaType.None
                select v).GetEnumerator();

            if (enumerator.MoveNext())
            {
                writer.WritePropertyName(propertyName);
                JsonSchemaType current = enumerator.Current;
                if (enumerator.MoveNext())
                {
                    writer.WriteStartArray();
                    writer.WriteValue(JsonSchemaBuilder.MapType(current));
                    do
                    {
                        writer.WriteValue(JsonSchemaBuilder.MapType(enumerator.Current));
                    }while (enumerator.MoveNext());
                    writer.WriteEndArray();
                    return;
                }
                writer.WriteValue(JsonSchemaBuilder.MapType(current));
            }
        }
All Usage Examples Of Newtonsoft.Json.Schema.JsonSchemaBuilder::MapType