3232using Exceptionless . Json . Utilities ;
3333using Exceptionless . Json . Linq ;
3434
35+ #nullable disable
36+
3537namespace Exceptionless . Json . Bson
3638{
3739 /// <summary>
38- /// Represents a reader that provides fast, non-cached, forward-only access to serialized JSON data.
40+ /// Represents a reader that provides fast, non-cached, forward-only access to serialized BSON data.
3941 /// </summary>
42+ [ Obsolete ( "BSON reading and writing has been moved to its own package. See https://www.nuget.org/packages/Exceptionless.Json.Bson for more details." ) ]
4043 internal class BsonReader : JsonReader
4144 {
4245 private const int MaxCharBytesSize = 128 ;
@@ -85,16 +88,16 @@ public ContainerContext(BsonType type)
8588 }
8689
8790 /// <summary>
88- /// Gets or sets a value indicating whether binary data reading should compatible with incorrect Json.NET 3.5 written binary.
91+ /// Gets or sets a value indicating whether binary data reading should be compatible with incorrect Json.NET 3.5 written binary.
8992 /// </summary>
9093 /// <value>
9194 /// <c>true</c> if binary data reading will be compatible with incorrect Json.NET 3.5 written binary; otherwise, <c>false</c>.
9295 /// </value>
9396 [ Obsolete ( "JsonNet35BinaryCompatibility will be removed in a future version of Json.NET." ) ]
9497 public bool JsonNet35BinaryCompatibility
9598 {
96- get { return _jsonNet35BinaryCompatibility ; }
97- set { _jsonNet35BinaryCompatibility = value ; }
99+ get => _jsonNet35BinaryCompatibility ;
100+ set => _jsonNet35BinaryCompatibility = value ;
98101 }
99102
100103 /// <summary>
@@ -105,8 +108,8 @@ public bool JsonNet35BinaryCompatibility
105108 /// </value>
106109 public bool ReadRootValueAsArray
107110 {
108- get { return _readRootValueAsArray ; }
109- set { _readRootValueAsArray = value ; }
111+ get => _readRootValueAsArray ;
112+ set => _readRootValueAsArray = value ;
110113 }
111114
112115 /// <summary>
@@ -115,14 +118,14 @@ public bool ReadRootValueAsArray
115118 /// <value>The <see cref="DateTimeKind" /> used when reading <see cref="DateTime"/> values from BSON.</value>
116119 public DateTimeKind DateTimeKindHandling
117120 {
118- get { return _dateTimeKindHandling ; }
119- set { _dateTimeKindHandling = value ; }
121+ get => _dateTimeKindHandling ;
122+ set => _dateTimeKindHandling = value ;
120123 }
121124
122125 /// <summary>
123126 /// Initializes a new instance of the <see cref="BsonReader"/> class.
124127 /// </summary>
125- /// <param name="stream">The stream .</param>
128+ /// <param name="stream">The <see cref="Stream"/> containing the BSON data to read .</param>
126129 public BsonReader ( Stream stream )
127130 : this ( stream , false , DateTimeKind . Local )
128131 {
@@ -131,7 +134,7 @@ public BsonReader(Stream stream)
131134 /// <summary>
132135 /// Initializes a new instance of the <see cref="BsonReader"/> class.
133136 /// </summary>
134- /// <param name="reader">The reader .</param>
137+ /// <param name="reader">The <see cref="BinaryReader"/> containing the BSON data to read .</param>
135138 public BsonReader ( BinaryReader reader )
136139 : this ( reader , false , DateTimeKind . Local )
137140 {
@@ -140,7 +143,7 @@ public BsonReader(BinaryReader reader)
140143 /// <summary>
141144 /// Initializes a new instance of the <see cref="BsonReader"/> class.
142145 /// </summary>
143- /// <param name="stream">The stream .</param>
146+ /// <param name="stream">The <see cref="Stream"/> containing the BSON data to read .</param>
144147 /// <param name="readRootValueAsArray">if set to <c>true</c> the root object will be read as a JSON array.</param>
145148 /// <param name="dateTimeKindHandling">The <see cref="DateTimeKind" /> used when reading <see cref="DateTime"/> values from BSON.</param>
146149 public BsonReader ( Stream stream , bool readRootValueAsArray , DateTimeKind dateTimeKindHandling )
@@ -155,7 +158,7 @@ public BsonReader(Stream stream, bool readRootValueAsArray, DateTimeKind dateTim
155158 /// <summary>
156159 /// Initializes a new instance of the <see cref="BsonReader"/> class.
157160 /// </summary>
158- /// <param name="reader">The reader .</param>
161+ /// <param name="reader">The <see cref="BinaryReader"/> containing the BSON data to read .</param>
159162 /// <param name="readRootValueAsArray">if set to <c>true</c> the root object will be read as a JSON array.</param>
160163 /// <param name="dateTimeKindHandling">The <see cref="DateTimeKind" /> used when reading <see cref="DateTime"/> values from BSON.</param>
161164 public BsonReader ( BinaryReader reader , bool readRootValueAsArray , DateTimeKind dateTimeKindHandling )
@@ -175,10 +178,10 @@ private string ReadElement()
175178 }
176179
177180 /// <summary>
178- /// Reads the next JSON token from the stream .
181+ /// Reads the next JSON token from the underlying <see cref="Stream"/> .
179182 /// </summary>
180183 /// <returns>
181- /// true if the next token was read successfully; false if there are no more tokens to read.
184+ /// <c> true</c> if the next token was read successfully; <c> false</c> if there are no more tokens to read.
182185 /// </returns>
183186 public override bool Read ( )
184187 {
@@ -223,18 +226,19 @@ public override bool Read()
223226 }
224227
225228 /// <summary>
226- /// Changes the <see cref="JsonReader.State"/> to Closed.
229+ /// Changes the reader's state to <see cref="JsonReader.State.Closed"/>.
230+ /// If <see cref="JsonReader.CloseInput"/> is set to <c>true</c>, the underlying <see cref="Stream"/> is also closed.
227231 /// </summary>
228232 public override void Close ( )
229233 {
230234 base . Close ( ) ;
231235
232- if ( CloseInput && _reader != null )
236+ if ( CloseInput )
233237 {
234- #if ! ( DOTNET || PORTABLE40 || PORTABLE || NETSTANDARD1_0 || NETSTANDARD1_1 || NETSTANDARD1_2 || NETSTANDARD1_3 || NETSTANDARD1_4 || NETSTANDARD1_5 )
235- _reader . Close ( ) ;
238+ #if HAVE_STREAM_READER_WRITER_CLOSE
239+ _reader ? . Close ( ) ;
236240#else
237- _reader . Dispose ( ) ;
241+ _reader ? . Dispose ( ) ;
238242#endif
239243 }
240244 }
@@ -368,6 +372,11 @@ private bool ReadNormal()
368372 ContainerContext context = _currentContext ;
369373 if ( context == null )
370374 {
375+ if ( SupportMultipleContent )
376+ {
377+ goto case State . Start ;
378+ }
379+
371380 return false ;
372381 }
373382
0 commit comments