JsonReaderSettings.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. using System;
  16. namespace MongoDB.Bson.IO
  17. {
  18. /// <summary>
  19. /// Represents settings for a JsonReader.
  20. /// </summary>
  21. [Serializable]
  22. public class JsonReaderSettings : BsonReaderSettings
  23. {
  24. // private static fields
  25. private static JsonReaderSettings __defaults = null; // delay creation to pick up the latest default values
  26. // constructors
  27. /// <summary>
  28. /// Initializes a new instance of the JsonReaderSettings class.
  29. /// </summary>
  30. public JsonReaderSettings()
  31. {
  32. }
  33. // public static properties
  34. /// <summary>
  35. /// Gets or sets the default settings for a JsonReader.
  36. /// </summary>
  37. public static JsonReaderSettings Defaults
  38. {
  39. get
  40. {
  41. if (__defaults == null)
  42. {
  43. __defaults = new JsonReaderSettings();
  44. }
  45. return __defaults;
  46. }
  47. set { __defaults = value; }
  48. }
  49. // public properties
  50. // public methods
  51. /// <summary>
  52. /// Creates a clone of the settings.
  53. /// </summary>
  54. /// <returns>A clone of the settings.</returns>
  55. public new JsonReaderSettings Clone()
  56. {
  57. return (JsonReaderSettings)CloneImplementation();
  58. }
  59. // protected methods
  60. /// <summary>
  61. /// Creates a clone of the settings.
  62. /// </summary>
  63. /// <returns>A clone of the settings.</returns>
  64. protected override BsonReaderSettings CloneImplementation()
  65. {
  66. var clone = new JsonReaderSettings();
  67. #pragma warning disable 618
  68. if (BsonDefaults.GuidRepresentationMode == GuidRepresentationMode.V2)
  69. {
  70. clone.GuidRepresentation = GuidRepresentation;
  71. }
  72. #pragma warning restore 618
  73. return clone;
  74. }
  75. }
  76. }