BsonSerializationArgs.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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.Serialization
  17. {
  18. /// <summary>
  19. /// Represents args common to all serializers.
  20. /// </summary>
  21. public struct BsonSerializationArgs
  22. {
  23. // private fields
  24. private Type _nominalType;
  25. private bool _serializeAsNominalType;
  26. private bool _serializeIdFirst;
  27. // constructors
  28. /// <summary>
  29. /// Initializes a new instance of the <see cref="BsonSerializationArgs"/> struct.
  30. /// </summary>
  31. /// <param name="nominalType">The nominal type.</param>
  32. /// <param name="serializeAsNominalType">Whether to serialize as the nominal type.</param>
  33. /// <param name="serializeIdFirst">Whether to serialize the id first.</param>
  34. public BsonSerializationArgs(
  35. Type nominalType,
  36. bool serializeAsNominalType,
  37. bool serializeIdFirst)
  38. {
  39. _nominalType = nominalType;
  40. _serializeAsNominalType = serializeAsNominalType;
  41. _serializeIdFirst = serializeIdFirst;
  42. }
  43. // public properties
  44. /// <summary>
  45. /// Gets or sets the nominal type.
  46. /// </summary>
  47. /// <value>
  48. /// The nominal type.
  49. /// </value>
  50. public Type NominalType
  51. {
  52. get { return _nominalType; }
  53. set { _nominalType = value; }
  54. }
  55. /// <summary>
  56. /// Gets or sets a value indicating whether to serialize the value as if it were an instance of the nominal type.
  57. /// </summary>
  58. public bool SerializeAsNominalType
  59. {
  60. get { return _serializeAsNominalType; }
  61. set { _serializeAsNominalType = value; }
  62. }
  63. /// <summary>
  64. /// Gets or sets a value indicating whether to serialize the id first.
  65. /// </summary>
  66. public bool SerializeIdFirst
  67. {
  68. get { return _serializeIdFirst; }
  69. set { _serializeIdFirst = value; }
  70. }
  71. }
  72. }