BsonDocumentWriterSettings.cs 2.9 KB

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