JsonWriterContext.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. internal class JsonWriterContext
  18. {
  19. // private fields
  20. private JsonWriterContext _parentContext;
  21. private ContextType _contextType;
  22. private string _indentation;
  23. private bool _hasElements = false;
  24. // constructors
  25. internal JsonWriterContext(JsonWriterContext parentContext, ContextType contextType, string indentChars)
  26. {
  27. _parentContext = parentContext;
  28. _contextType = contextType;
  29. _indentation = (parentContext == null) ? indentChars : parentContext.Indentation + indentChars;
  30. }
  31. // internal properties
  32. internal JsonWriterContext ParentContext
  33. {
  34. get { return _parentContext; }
  35. }
  36. internal ContextType ContextType
  37. {
  38. get { return _contextType; }
  39. }
  40. internal string Indentation
  41. {
  42. get { return _indentation; }
  43. }
  44. internal bool HasElements
  45. {
  46. get { return _hasElements; }
  47. set { _hasElements = value; }
  48. }
  49. }
  50. }