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

ProcessOptions() private method

private ProcessOptions ( ) : void
return void
    private void ProcessOptions()
    {
      CurrentSchema.Options = new Dictionary<JToken, string>(new JTokenEqualityComparer());

      switch (_reader.TokenType)
      {
        case JsonToken.StartArray:
          while (_reader.Read() && _reader.TokenType != JsonToken.EndArray)
          {
            if (_reader.TokenType != JsonToken.StartObject)
              throw new Exception("Expect object token, got {0}.".FormatWith(CultureInfo.InvariantCulture, _reader.TokenType));

            string label = null;
            JToken value = null;

            while (_reader.Read() && _reader.TokenType != JsonToken.EndObject)
            {
              string propertyName = Convert.ToString(_reader.Value, CultureInfo.InvariantCulture);
              _reader.Read();

              switch (propertyName)
              {
                case JsonSchemaConstants.OptionValuePropertyName:
                  value = JToken.ReadFrom(_reader);
                  break;
                case JsonSchemaConstants.OptionLabelPropertyName:
                  label = (string) _reader.Value;
                  break;
                default:
                  throw new Exception("Unexpected property in JSON schema option: {0}.".FormatWith(CultureInfo.InvariantCulture, propertyName));
              }
            }

            if (value == null)
              throw new Exception("No value specified for JSON schema option.");

            if (CurrentSchema.Options.ContainsKey(value))
              throw new Exception("Duplicate value in JSON schema option collection: {0}".FormatWith(CultureInfo.InvariantCulture, value));

            CurrentSchema.Options.Add(value, label);
          }
          break;
        default:
          throw new Exception("Expected array token, got {0}.".FormatWith(CultureInfo.InvariantCulture, _reader.TokenType));
      }
    }