JsonReaderBookmark.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* Copyright 2010-present MongoDB Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. namespace MongoDB.Bson.IO
  16. {
  17. /// <summary>
  18. /// Represents a bookmark that can be used to return a reader to the current position and state.
  19. /// </summary>
  20. public class JsonReaderBookmark : BsonReaderBookmark
  21. {
  22. // private fields
  23. private JsonReaderContext _context;
  24. private JsonToken _currentToken;
  25. private BsonValue _currentValue;
  26. private JsonToken _pushedToken;
  27. private int _position;
  28. // constructors
  29. internal JsonReaderBookmark(
  30. BsonReaderState state,
  31. BsonType currentBsonType,
  32. string currentName,
  33. JsonReaderContext context,
  34. JsonToken currentToken,
  35. BsonValue currentValue,
  36. JsonToken pushedToken,
  37. int position)
  38. : base(state, currentBsonType, currentName)
  39. {
  40. _context = context.Clone();
  41. _currentToken = currentToken;
  42. _currentValue = currentValue;
  43. _pushedToken = pushedToken;
  44. _position = position;
  45. }
  46. // internal properties
  47. internal JsonToken CurrentToken
  48. {
  49. get { return _currentToken; }
  50. }
  51. internal BsonValue CurrentValue
  52. {
  53. get { return _currentValue; }
  54. }
  55. internal int Position
  56. {
  57. get { return _position; }
  58. }
  59. internal JsonToken PushedToken
  60. {
  61. get { return _pushedToken; }
  62. }
  63. // internal methods
  64. internal JsonReaderContext CloneContext()
  65. {
  66. return _context.Clone();
  67. }
  68. }
  69. }