BsonReaderBookmark.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* Copyright 2010-2014 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 abstract class BsonReaderBookmark
  21. {
  22. // private fields
  23. private BsonReaderState _state;
  24. private BsonType _currentBsonType;
  25. private string _currentName;
  26. // constructors
  27. /// <summary>
  28. /// Initializes a new instance of the BsonReaderBookmark class.
  29. /// </summary>
  30. /// <param name="state">The state of the reader.</param>
  31. /// <param name="currentBsonType">The current BSON type.</param>
  32. /// <param name="currentName">The name of the current element.</param>
  33. protected BsonReaderBookmark(BsonReaderState state, BsonType currentBsonType, string currentName)
  34. {
  35. _state = state;
  36. _currentBsonType = currentBsonType;
  37. _currentName = currentName;
  38. }
  39. // public properties
  40. /// <summary>
  41. /// Gets the current state of the reader.
  42. /// </summary>
  43. public BsonReaderState State
  44. {
  45. get { return _state; }
  46. }
  47. /// <summary>
  48. /// Gets the current BsonType;
  49. /// </summary>
  50. public BsonType CurrentBsonType
  51. {
  52. get { return _currentBsonType; }
  53. }
  54. /// <summary>
  55. /// Gets the name of the current element.
  56. /// </summary>
  57. public string CurrentName
  58. {
  59. get { return _currentName; }
  60. }
  61. }
  62. }