Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/Newtonsoft.Json.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Src/Newtonsoft.Json/Bson/BsonReader.cs')
-rw-r--r--Src/Newtonsoft.Json/Bson/BsonReader.cs20
1 files changed, 17 insertions, 3 deletions
diff --git a/Src/Newtonsoft.Json/Bson/BsonReader.cs b/Src/Newtonsoft.Json/Bson/BsonReader.cs
index 5d377a7..c80491d 100644
--- a/Src/Newtonsoft.Json/Bson/BsonReader.cs
+++ b/Src/Newtonsoft.Json/Bson/BsonReader.cs
@@ -350,26 +350,40 @@ namespace Newtonsoft.Json.Bson
{
try
{
+ bool success;
+
switch (_bsonReaderState)
{
case BsonReaderState.Normal:
- return ReadNormal();
+ success = ReadNormal();
+ break;
case BsonReaderState.ReferenceStart:
case BsonReaderState.ReferenceRef:
case BsonReaderState.ReferenceId:
- return ReadReference();
+ success = ReadReference();
+ break;
case BsonReaderState.CodeWScopeStart:
case BsonReaderState.CodeWScopeCode:
case BsonReaderState.CodeWScopeScope:
case BsonReaderState.CodeWScopeScopeObject:
case BsonReaderState.CodeWScopeScopeEnd:
- return ReadCodeWScope();
+ success = ReadCodeWScope();
+ break;
default:
throw CreateReaderException(this, "Unexpected state: {0}".FormatWith(CultureInfo.InvariantCulture, _bsonReaderState));
}
+
+ if (!success)
+ {
+ SetToken(JsonToken.None);
+ return false;
+ }
+
+ return true;
}
catch (EndOfStreamException)
{
+ SetToken(JsonToken.None);
return false;
}
}