JsonReaderSettings.cs 2.3 KB

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