Represents settings for a JsonReader.
 // constructors
 /// <summary>
 /// Initializes a new instance of the JsonReader class.
 /// </summary>
 /// <param name="buffer">The buffer.</param>
 /// <param name="settings">The reader settings.</param>
 public JsonReader(JsonBuffer buffer, JsonReaderSettings settings)
     : base(settings)
 {
     _buffer = buffer;
     _jsonReaderSettings = settings; // already frozen by base class
     _context = new JsonReaderContext(null, ContextType.TopLevel);
 }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the JsonReader class.
 /// </summary>
 /// <param name="buffer">The buffer.</param>
 /// <param name="settings">The reader settings.</param>
 public JsonReader(
     JsonBuffer buffer,
     JsonReaderSettings settings
 ) {
     this.buffer = buffer;
     this.settings = settings.Freeze();
     this.context = new JsonReaderContext(null, ContextType.TopLevel);
 }
 // protected methods
 /// <summary>
 /// Creates a clone of the settings.
 /// </summary>
 /// <returns>A clone of the settings.</returns>
 protected override BsonReaderSettings CloneImplementation()
 {
     var clone = new JsonReaderSettings
     {
         GuidRepresentation = GuidRepresentation
     };
     return clone;
 }
 // methods
 /// <summary>
 /// Creates a JsonReader for this encoder.
 /// </summary>
 /// <returns>A JsonReader.</returns>
 public JsonReader CreateJsonReader()
 {
     if (_textReader == null)
     {
         throw new InvalidOperationException("No TextReader was provided.");
     }
     
     var readerSettings = new JsonReaderSettings();
     if (_encoderSettings != null)
     {
         readerSettings.GuidRepresentation = _encoderSettings.GetOrDefault(MessageEncoderSettingsName.GuidRepresentation, GuidRepresentation.CSharpLegacy);
     }
     return new JsonReader(_textReader, readerSettings);
 }
 /// <summary>
 /// Creates a BsonReader for a JsonBuffer.
 /// </summary>
 /// <param name="buffer">The buffer.</param>
 /// <param name="settings">The settings.</param>
 /// <returns>A BsonReader.</returns>
 public static BsonReader Create(JsonBuffer buffer, JsonReaderSettings settings)
 {
     return new JsonReader(buffer, settings);
 }
示例#6
0
 /// <summary>
 /// Initializes a new instance of the JsonReader class.
 /// </summary>
 /// <param name="textReader">The TextReader.</param>
 /// <param name="settings">The reader settings.</param>
 public JsonReader(TextReader textReader, JsonReaderSettings settings)
     : this(new JsonBuffer(textReader), settings)
 {
 }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the JsonReader class.
 /// </summary>
 /// <param name="json">The JSON string.</param>
 /// <param name="settings">The reader settings.</param>
 public JsonReader(string json, JsonReaderSettings settings)
     : this(new JsonBuffer(json), settings)
 {
 }