BsonDocumentWriterSettings.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 BsonDocumentWriter.
  20. /// </summary>
  21. #if NET45
  22. [Serializable]
  23. #endif
  24. public class BsonDocumentWriterSettings : BsonWriterSettings
  25. {
  26. // private static fields
  27. private static BsonDocumentWriterSettings __defaults = null; // delay creation to pick up the latest default values
  28. // constructors
  29. /// <summary>
  30. /// Initializes a new instance of the BsonDocumentWriterSettings class.
  31. /// </summary>
  32. public BsonDocumentWriterSettings()
  33. {
  34. }
  35. /// <summary>
  36. /// Initializes a new instance of the BsonDocumentWriterSettings class.
  37. /// </summary>
  38. /// <param name="guidRepresentation">The representation for Guids.</param>
  39. [Obsolete("Use the no-argument constructor instead and set the properties.")]
  40. public BsonDocumentWriterSettings(GuidRepresentation guidRepresentation)
  41. : base(guidRepresentation)
  42. {
  43. }
  44. // public static properties
  45. /// <summary>
  46. /// Gets or sets the default BsonDocumentWriter settings.
  47. /// </summary>
  48. public static BsonDocumentWriterSettings Defaults
  49. {
  50. get
  51. {
  52. if (__defaults == null)
  53. {
  54. __defaults = new BsonDocumentWriterSettings();
  55. }
  56. return __defaults;
  57. }
  58. set { __defaults = value; }
  59. }
  60. // public methods
  61. /// <summary>
  62. /// Creates a clone of the settings.
  63. /// </summary>
  64. /// <returns>A clone of the settings.</returns>
  65. public new BsonDocumentWriterSettings Clone()
  66. {
  67. return (BsonDocumentWriterSettings)CloneImplementation();
  68. }
  69. // protected methods
  70. /// <summary>
  71. /// Creates a clone of the settings.
  72. /// </summary>
  73. /// <returns>A clone of the settings.</returns>
  74. protected override BsonWriterSettings CloneImplementation()
  75. {
  76. var clone = new BsonDocumentWriterSettings
  77. {
  78. GuidRepresentation = GuidRepresentation,
  79. MaxSerializationDepth = MaxSerializationDepth
  80. };
  81. return clone;
  82. }
  83. }
  84. }