JsonReaderContext.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. internal class JsonReaderContext
  18. {
  19. // private fields
  20. private JsonReaderContext _parentContext;
  21. private ContextType _contextType;
  22. // constructors
  23. // used by Clone
  24. private JsonReaderContext()
  25. {
  26. }
  27. internal JsonReaderContext(JsonReaderContext parentContext, ContextType contextType)
  28. {
  29. _parentContext = parentContext;
  30. _contextType = contextType;
  31. }
  32. // internal properties
  33. internal ContextType ContextType
  34. {
  35. get { return _contextType; }
  36. }
  37. // public methods
  38. /// <summary>
  39. /// Creates a clone of the context.
  40. /// </summary>
  41. /// <returns>A clone of the context.</returns>
  42. public JsonReaderContext Clone()
  43. {
  44. return new JsonReaderContext(_parentContext, _contextType);
  45. }
  46. public JsonReaderContext PopContext()
  47. {
  48. return _parentContext;
  49. }
  50. }
  51. }