// protected methods protected virtual void ReplaceCurrentToken(Newtonsoft.Json.JsonToken tokenType, object value = null, BsonValue bsonValue = null) { if (!tokenType.IsScalar()) { var message = string.Format("New tokenType must be scalar, not: {0}.", tokenType); throw new ArgumentException(message, "tokenType"); } if (!_tokenType.IsScalar() && _tokenType != Newtonsoft.Json.JsonToken.EndArray && _tokenType != Newtonsoft.Json.JsonToken.EndObject) { var message = string.Format("Current tokenType must be scalar, not: {0}.", _tokenType); throw new InvalidOperationException(message); } _tokenType = tokenType; _value = value; _bsonValue = bsonValue; }