Skip to content
Browse files

CSHARP-635: Postpone creation of serializers until they are first nee…

…ded.
  • Loading branch information...
1 parent 351e4ba commit 5dabdce56d47b47dcd95edd738a4ea8fc78de4e4 rstam committed Dec 31, 2012
Showing with 180 additions and 106 deletions.
  1. +62 −62 MongoDB.Bson/Serialization/BsonDefaultSerializationProvider.cs
  2. +1 −0 MongoDB.Bson/Serialization/Options/DateTimeSerializationOptions.cs
  3. +1 −0 MongoDB.Bson/Serialization/Options/DictionarySerializationOptions.cs
  4. +1 −0 MongoDB.Bson/Serialization/Serializers/BitArraySerializer.cs
  5. +1 −0 MongoDB.Bson/Serialization/Serializers/BitmapSerializer.cs
  6. +1 −0 MongoDB.Bson/Serialization/Serializers/BooleanSerializer.cs
  7. +1 −0 MongoDB.Bson/Serialization/Serializers/ByteArraySerializer.cs
  8. +1 −0 MongoDB.Bson/Serialization/Serializers/ByteSerializer.cs
  9. +1 −0 MongoDB.Bson/Serialization/Serializers/CharSerializer.cs
  10. +1 −0 MongoDB.Bson/Serialization/Serializers/CultureInfoSerializer.cs
  11. +1 −0 MongoDB.Bson/Serialization/Serializers/DateTimeOffsetSerializer.cs
  12. +13 −1 MongoDB.Bson/Serialization/Serializers/DateTimeSerializer.cs
  13. +1 −0 MongoDB.Bson/Serialization/Serializers/DecimalSerializer.cs
  14. +12 −1 MongoDB.Bson/Serialization/Serializers/DictionaryGenericSerializer.cs
  15. +13 −1 MongoDB.Bson/Serialization/Serializers/DictionarySerializer.cs
  16. +1 −0 MongoDB.Bson/Serialization/Serializers/DoubleSerializer.cs
  17. +1 −0 MongoDB.Bson/Serialization/Serializers/DrawingSizeSerializer.cs
  18. +1 −0 MongoDB.Bson/Serialization/Serializers/EnumSerializer.cs
  19. +1 −0 MongoDB.Bson/Serialization/Serializers/EnumerableSerializer.cs
  20. +1 −0 MongoDB.Bson/Serialization/Serializers/GuidSerializer.cs
  21. +1 −0 MongoDB.Bson/Serialization/Serializers/IPAddressSerializer.cs
  22. +1 −0 MongoDB.Bson/Serialization/Serializers/IPEndPointSerializer.cs
  23. +1 −0 MongoDB.Bson/Serialization/Serializers/ImageSerializer.cs
  24. +1 −0 MongoDB.Bson/Serialization/Serializers/Int16Serializer.cs
  25. +1 −0 MongoDB.Bson/Serialization/Serializers/Int32Serializer.cs
  26. +1 −0 MongoDB.Bson/Serialization/Serializers/Int64Serializer.cs
  27. +1 −0 MongoDB.Bson/Serialization/Serializers/ObjectIdSerializer.cs
  28. +1 −0 MongoDB.Bson/Serialization/Serializers/ObjectSerializer.cs
  29. +1 −0 MongoDB.Bson/Serialization/Serializers/QueueSerializer.cs
  30. +1 −0 MongoDB.Bson/Serialization/Serializers/SByteSerializer.cs
  31. +1 −0 MongoDB.Bson/Serialization/Serializers/SingleSerializer.cs
  32. +1 −0 MongoDB.Bson/Serialization/Serializers/StackSerializer.cs
  33. +1 −0 MongoDB.Bson/Serialization/Serializers/StringSerializer.cs
  34. +1 −0 MongoDB.Bson/Serialization/Serializers/TimeSpanSerializer.cs
  35. +1 −0 MongoDB.Bson/Serialization/Serializers/UInt16Serializer.cs
  36. +1 −0 MongoDB.Bson/Serialization/Serializers/UInt32Serializer.cs
  37. +1 −0 MongoDB.Bson/Serialization/Serializers/UInt64Serializer.cs
  38. +1 −0 MongoDB.Bson/Serialization/Serializers/UriSerializer.cs
  39. +1 −0 MongoDB.Bson/Serialization/Serializers/VersionSerializer.cs
  40. +2 −1 MongoDB.Driver/Linq/Translators/PredicateTranslator.cs
  41. +2 −2 MongoDB.Driver/MongoDBRef.cs
  42. +41 −38 MongoDB.Driver/SystemProfileInfo.cs
View
124 MongoDB.Bson/Serialization/BsonDefaultSerializationProvider.cs
@@ -33,68 +33,68 @@ namespace MongoDB.Bson.Serialization
internal class BsonDefaultSerializationProvider : IBsonSerializationProvider
{
// private static fields
- private static Dictionary<Type, IBsonSerializer> __serializers;
+ private static Dictionary<Type, Type> __serializers;
private static Dictionary<Type, Type> __genericSerializerDefinitions;
// static constructor
static BsonDefaultSerializationProvider()
{
- __serializers = new Dictionary<Type, IBsonSerializer>
+ __serializers = new Dictionary<Type, Type>
{
- { typeof(BitArray), BitArraySerializer.Instance },
- { typeof(Bitmap), BitmapSerializer.Instance },
- { typeof(Boolean), BooleanSerializer.Instance },
- { typeof(BsonArray), BsonArraySerializer.Instance },
- { typeof(BsonBinaryData), BsonBinaryDataSerializer.Instance },
- { typeof(BsonBoolean), BsonBooleanSerializer.Instance },
- { typeof(BsonDateTime), BsonDateTimeSerializer.Instance },
- { typeof(BsonDocument), BsonDocumentSerializer.Instance },
- { typeof(BsonDocumentWrapper), BsonDocumentWrapperSerializer.Instance },
- { typeof(BsonDouble), BsonDoubleSerializer.Instance },
- { typeof(BsonInt32), BsonInt32Serializer.Instance },
- { typeof(BsonInt64), BsonInt64Serializer.Instance },
- { typeof(BsonJavaScript), BsonJavaScriptSerializer.Instance },
- { typeof(BsonJavaScriptWithScope), BsonJavaScriptWithScopeSerializer.Instance },
- { typeof(BsonMaxKey), BsonMaxKeySerializer.Instance },
- { typeof(BsonMinKey), BsonMinKeySerializer.Instance },
- { typeof(BsonNull), BsonNullSerializer.Instance },
- { typeof(BsonObjectId), BsonObjectIdSerializer.Instance },
- { typeof(BsonRegularExpression), BsonRegularExpressionSerializer.Instance },
- { typeof(BsonString), BsonStringSerializer.Instance },
- { typeof(BsonSymbol), BsonSymbolSerializer.Instance },
- { typeof(BsonTimestamp), BsonTimestampSerializer.Instance },
- { typeof(BsonUndefined), BsonUndefinedSerializer.Instance },
- { typeof(BsonValue), BsonValueSerializer.Instance },
- { typeof(Byte), ByteSerializer.Instance },
- { typeof(Byte[]), ByteArraySerializer.Instance },
- { typeof(Char), CharSerializer.Instance },
- { typeof(CultureInfo), CultureInfoSerializer.Instance },
- { typeof(DateTime), DateTimeSerializer.Instance },
- { typeof(DateTimeOffset), DateTimeOffsetSerializer.Instance },
- { typeof(Decimal), DecimalSerializer.Instance },
- { typeof(Double), DoubleSerializer.Instance },
- { typeof(System.Drawing.Size), DrawingSizeSerializer.Instance },
- { typeof(Guid), GuidSerializer.Instance },
- { typeof(IBsonSerializable), BsonIBsonSerializableSerializer.Instance },
- { typeof(Image), ImageSerializer.Instance },
- { typeof(Int16), Int16Serializer.Instance },
- { typeof(Int32), Int32Serializer.Instance },
- { typeof(Int64), Int64Serializer.Instance },
- { typeof(IPAddress), IPAddressSerializer.Instance },
- { typeof(IPEndPoint), IPEndPointSerializer.Instance },
- { typeof(Object), ObjectSerializer.Instance },
- { typeof(ObjectId), ObjectIdSerializer.Instance },
- { typeof(Queue), QueueSerializer.Instance },
- { typeof(SByte), SByteSerializer.Instance },
- { typeof(Single), SingleSerializer.Instance },
- { typeof(Stack), StackSerializer.Instance },
- { typeof(String), StringSerializer.Instance },
- { typeof(TimeSpan), TimeSpanSerializer.Instance },
- { typeof(UInt16), UInt16Serializer.Instance },
- { typeof(UInt32), UInt32Serializer.Instance },
- { typeof(UInt64), UInt64Serializer.Instance },
- { typeof(Uri), UriSerializer.Instance },
- { typeof(Version), VersionSerializer.Instance }
+ { typeof(BitArray), typeof(BitArraySerializer) },
+ { typeof(Bitmap), typeof(BitmapSerializer) },
+ { typeof(Boolean), typeof(BooleanSerializer) },
+ { typeof(BsonArray), typeof(BsonArraySerializer) },
+ { typeof(BsonBinaryData), typeof(BsonBinaryDataSerializer) },
+ { typeof(BsonBoolean), typeof(BsonBooleanSerializer) },
+ { typeof(BsonDateTime), typeof(BsonDateTimeSerializer) },
+ { typeof(BsonDocument), typeof(BsonDocumentSerializer) },
+ { typeof(BsonDocumentWrapper), typeof(BsonDocumentWrapperSerializer) },
+ { typeof(BsonDouble), typeof(BsonDoubleSerializer) },
+ { typeof(BsonInt32), typeof(BsonInt32Serializer) },
+ { typeof(BsonInt64), typeof(BsonInt64Serializer) },
+ { typeof(BsonJavaScript), typeof(BsonJavaScriptSerializer) },
+ { typeof(BsonJavaScriptWithScope), typeof(BsonJavaScriptWithScopeSerializer) },
+ { typeof(BsonMaxKey), typeof(BsonMaxKeySerializer) },
+ { typeof(BsonMinKey), typeof(BsonMinKeySerializer) },
+ { typeof(BsonNull), typeof(BsonNullSerializer) },
+ { typeof(BsonObjectId), typeof(BsonObjectIdSerializer) },
+ { typeof(BsonRegularExpression), typeof(BsonRegularExpressionSerializer) },
+ { typeof(BsonString), typeof(BsonStringSerializer) },
+ { typeof(BsonSymbol), typeof(BsonSymbolSerializer) },
+ { typeof(BsonTimestamp), typeof(BsonTimestampSerializer) },
+ { typeof(BsonUndefined), typeof(BsonUndefinedSerializer) },
+ { typeof(BsonValue), typeof(BsonValueSerializer) },
+ { typeof(Byte), typeof(ByteSerializer) },
+ { typeof(Byte[]), typeof(ByteArraySerializer) },
+ { typeof(Char), typeof(CharSerializer) },
+ { typeof(CultureInfo), typeof(CultureInfoSerializer) },
+ { typeof(DateTime), typeof(DateTimeSerializer) },
+ { typeof(DateTimeOffset), typeof(DateTimeOffsetSerializer) },
+ { typeof(Decimal), typeof(DecimalSerializer) },
+ { typeof(Double), typeof(DoubleSerializer) },
+ { typeof(System.Drawing.Size), typeof(DrawingSizeSerializer) },
+ { typeof(Guid), typeof(GuidSerializer) },
+ { typeof(IBsonSerializable), typeof(BsonIBsonSerializableSerializer) },
+ { typeof(Image), typeof(ImageSerializer) },
+ { typeof(Int16), typeof(Int16Serializer) },
+ { typeof(Int32), typeof(Int32Serializer) },
+ { typeof(Int64), typeof(Int64Serializer) },
+ { typeof(IPAddress), typeof(IPAddressSerializer) },
+ { typeof(IPEndPoint), typeof(IPEndPointSerializer) },
+ { typeof(Object), typeof(ObjectSerializer) },
+ { typeof(ObjectId), typeof(ObjectIdSerializer) },
+ { typeof(Queue), typeof(QueueSerializer) },
+ { typeof(SByte), typeof(SByteSerializer) },
+ { typeof(Single), typeof(SingleSerializer) },
+ { typeof(Stack), typeof(StackSerializer) },
+ { typeof(String), typeof(StringSerializer) },
+ { typeof(TimeSpan), typeof(TimeSpanSerializer) },
+ { typeof(UInt16), typeof(UInt16Serializer) },
+ { typeof(UInt32), typeof(UInt32Serializer) },
+ { typeof(UInt64), typeof(UInt64Serializer) },
+ { typeof(Uri), typeof(UriSerializer) },
+ { typeof(Version), typeof(VersionSerializer) }
};
__genericSerializerDefinitions = new Dictionary<Type, Type>
@@ -122,10 +122,10 @@ public BsonDefaultSerializationProvider()
/// <returns>The serializer.</returns>
public IBsonSerializer GetSerializer(Type type)
{
- IBsonSerializer serializer;
- if (__serializers.TryGetValue(type, out serializer))
+ Type serializerType;
+ if (__serializers.TryGetValue(type, out serializerType))
{
- return serializer;
+ return (IBsonSerializer)Activator.CreateInstance(serializerType);
}
if (typeof(BsonDocument).IsAssignableFrom(type))
@@ -169,7 +169,7 @@ public IBsonSerializer GetSerializer(Type type)
if (type.IsEnum)
{
- return EnumSerializer.Instance;
+ return new EnumSerializer();
}
// classes that implement IDictionary or IEnumerable are serialized using either DictionarySerializer or EnumerableSerializer
@@ -234,7 +234,7 @@ private IBsonSerializer GetCollectionSerializer(Type type)
}
else if (implementedDictionaryInterface != null)
{
- return DictionarySerializer.Instance;
+ return new DictionarySerializer();
}
else if (implementedGenericEnumerableInterface != null)
{
@@ -258,7 +258,7 @@ private IBsonSerializer GetCollectionSerializer(Type type)
}
else if (implementedEnumerableInterface != null)
{
- return EnumerableSerializer.Instance;
+ return new EnumerableSerializer();
}
return null;
View
1 MongoDB.Bson/Serialization/Options/DateTimeSerializationOptions.cs
@@ -96,6 +96,7 @@ public static DateTimeSerializationOptions DateOnlyInstance
/// <summary>
/// Gets or sets the default DateTime serialization options.
/// </summary>
+ [Obsolete("Create and register a DateTimeSerializer with the desired options instead.")]
public static DateTimeSerializationOptions Defaults
{
get { return __defaults; }
View
1 MongoDB.Bson/Serialization/Options/DictionarySerializationOptions.cs
@@ -114,6 +114,7 @@ public static DictionarySerializationOptions ArrayOfDocuments
/// <summary>
/// Gets or sets the default Dictionary serialization options.
/// </summary>
+ [Obsolete("Create and register a DictionarySerializer with the desired options instead.")]
public static DictionarySerializationOptions Defaults
{
get { return __defaults; }
View
1 MongoDB.Bson/Serialization/Serializers/BitArraySerializer.cs
@@ -46,6 +46,7 @@ public BitArraySerializer()
/// <summary>
/// Gets an instance of the BitArraySerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static BitArraySerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/BitmapSerializer.cs
@@ -51,6 +51,7 @@ public BitmapSerializer()
/// <summary>
/// Gets an instance of the BitmapSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static BitmapSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/BooleanSerializer.cs
@@ -46,6 +46,7 @@ public BooleanSerializer()
/// <summary>
/// Gets an instance of the BooleanSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static BooleanSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/ByteArraySerializer.cs
@@ -46,6 +46,7 @@ public ByteArraySerializer()
/// <summary>
/// Gets an instance of the ByteArraySerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static ByteArraySerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/ByteSerializer.cs
@@ -46,6 +46,7 @@ public ByteSerializer()
/// <summary>
/// Gets an instance of the ByteSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static ByteSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/CharSerializer.cs
@@ -45,6 +45,7 @@ public CharSerializer()
/// <summary>
/// Gets an instance of the CharSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static CharSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/CultureInfoSerializer.cs
@@ -44,6 +44,7 @@ public CultureInfoSerializer()
/// <summary>
/// Gets an instance of the CultureInfoSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static CultureInfoSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/DateTimeOffsetSerializer.cs
@@ -47,6 +47,7 @@ public DateTimeOffsetSerializer()
/// <summary>
/// Gets an instance of the DateTimeOffsetSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static DateTimeOffsetSerializer Instance
{
get { return __instance; }
View
14 MongoDB.Bson/Serialization/Serializers/DateTimeSerializer.cs
@@ -38,14 +38,26 @@ public class DateTimeSerializer : BsonBaseSerializer
/// Initializes a new instance of the DateTimeSerializer class.
/// </summary>
public DateTimeSerializer()
- : base(DateTimeSerializationOptions.Defaults)
+#pragma warning disable 618
+ : this(DateTimeSerializationOptions.Defaults)
+#pragma warning restore
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the DateTimeSerializer class.
+ /// </summary>
+ /// <param name="defaultSerializationOptions">The default serialization options.</param>
+ public DateTimeSerializer(DateTimeSerializationOptions defaultSerializationOptions)
+ : base(defaultSerializationOptions)
{
}
// public static properties
/// <summary>
/// Gets an instance of the DateTimeSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static DateTimeSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/DecimalSerializer.cs
@@ -46,6 +46,7 @@ public DecimalSerializer()
/// <summary>
/// Gets an instance of the DecimalSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static DecimalSerializer Instance
{
get { return __instance; }
View
13 MongoDB.Bson/Serialization/Serializers/DictionaryGenericSerializer.cs
@@ -40,7 +40,18 @@ public class DictionarySerializer<TKey, TValue> : BsonBaseSerializer
/// Initializes a new instance of the DictionarySerializer class.
/// </summary>
public DictionarySerializer()
- : base(DictionarySerializationOptions.Defaults)
+#pragma warning disable 618
+ : this(DictionarySerializationOptions.Defaults)
+#pragma warning restore
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the DictionarySerializer class.
+ /// </summary>
+ /// <param name="defaultSerializationOptions">The default serialization options.</param>
+ public DictionarySerializer(DictionarySerializationOptions defaultSerializationOptions)
+ : base(defaultSerializationOptions)
{
_keyValuePairSerializer = new KeyValuePairSerializer<TKey, TValue>();
}
View
14 MongoDB.Bson/Serialization/Serializers/DictionarySerializer.cs
@@ -43,7 +43,18 @@ public class DictionarySerializer : BsonBaseSerializer
/// Initializes a new instance of the DictionarySerializer class.
/// </summary>
public DictionarySerializer()
- : base(DictionarySerializationOptions.Defaults)
+#pragma warning disable 618
+ : this(DictionarySerializationOptions.Defaults)
+#pragma warning restore
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the DictionarySerializer class.
+ /// </summary>
+ /// <param name="defaultSerializationOptions">The default serialization options.</param>
+ public DictionarySerializer(DictionarySerializationOptions defaultSerializationOptions)
+ : base(defaultSerializationOptions)
{
_keyValuePairSerializer = new KeyValuePairSerializer<object, object>();
}
@@ -52,6 +63,7 @@ public DictionarySerializer()
/// <summary>
/// Gets an instance of the DictionarySerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static DictionarySerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/DoubleSerializer.cs
@@ -47,6 +47,7 @@ public DoubleSerializer()
/// <summary>
/// Gets an instance of the DoubleSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static DoubleSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/DrawingSizeSerializer.cs
@@ -43,6 +43,7 @@ public DrawingSizeSerializer()
/// <summary>
/// Gets an instance of the DrawingSizeSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static DrawingSizeSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/EnumSerializer.cs
@@ -47,6 +47,7 @@ public EnumSerializer()
/// <summary>
/// Gets an instance of the EnumSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static EnumSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/EnumerableSerializer.cs
@@ -46,6 +46,7 @@ public EnumerableSerializer()
/// <summary>
/// Gets an instance of the EnumerableSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static EnumerableSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/GuidSerializer.cs
@@ -45,6 +45,7 @@ public GuidSerializer()
/// <summary>
/// Gets an instance of the GuidSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static GuidSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/IPAddressSerializer.cs
@@ -45,6 +45,7 @@ public IPAddressSerializer()
/// <summary>
/// Gets an instance of the IPAddressSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static IPAddressSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/IPEndPointSerializer.cs
@@ -46,6 +46,7 @@ public IPEndPointSerializer()
/// <summary>
/// Gets an instance of the IPEndPointSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static IPEndPointSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/ImageSerializer.cs
@@ -44,6 +44,7 @@ public ImageSerializer()
/// <summary>
/// Gets an instance of the ImageSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static ImageSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/Int16Serializer.cs
@@ -46,6 +46,7 @@ public Int16Serializer()
/// <summary>
/// Gets an instance of the Int16Serializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static Int16Serializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/Int32Serializer.cs
@@ -46,6 +46,7 @@ public Int32Serializer()
/// <summary>
/// Gets an instance of the Int32Serializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static Int32Serializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/Int64Serializer.cs
@@ -46,6 +46,7 @@ public Int64Serializer()
/// <summary>
/// Gets an instance of the Int64Serializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static Int64Serializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/ObjectIdSerializer.cs
@@ -45,6 +45,7 @@ public ObjectIdSerializer()
/// <summary>
/// Gets an instance of the ObjectIdSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static ObjectIdSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/ObjectSerializer.cs
@@ -45,6 +45,7 @@ public ObjectSerializer()
/// <summary>
/// Gets an instance of the ObjectSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static ObjectSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/QueueSerializer.cs
@@ -46,6 +46,7 @@ public QueueSerializer()
/// <summary>
/// Gets an instance of the QueueSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static QueueSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/SByteSerializer.cs
@@ -46,6 +46,7 @@ public SByteSerializer()
/// <summary>
/// Gets an instance of the SByteSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static SByteSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/SingleSerializer.cs
@@ -47,6 +47,7 @@ public SingleSerializer()
/// <summary>
/// Gets an instance of the SingleSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static SingleSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/StackSerializer.cs
@@ -46,6 +46,7 @@ public StackSerializer()
/// <summary>
/// Gets an instance of the StackSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static StackSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/StringSerializer.cs
@@ -45,6 +45,7 @@ public StringSerializer()
/// <summary>
/// Gets an instance of the StringSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static StringSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/TimeSpanSerializer.cs
@@ -45,6 +45,7 @@ public TimeSpanSerializer()
/// <summary>
/// Gets an instance of the TimeSpanSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static TimeSpanSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/UInt16Serializer.cs
@@ -46,6 +46,7 @@ public UInt16Serializer()
/// <summary>
/// Gets an instance of the UInt16Serializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static UInt16Serializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/UInt32Serializer.cs
@@ -46,6 +46,7 @@ public UInt32Serializer()
/// <summary>
/// Gets an instance of the UInt32Serializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static UInt32Serializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/UInt64Serializer.cs
@@ -46,6 +46,7 @@ public UInt64Serializer()
/// <summary>
/// Gets an instance of the UInt64Serializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static UInt64Serializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/UriSerializer.cs
@@ -43,6 +43,7 @@ public UriSerializer()
/// <summary>
/// Gets an instance of the UriSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static UriSerializer Instance
{
get { return __instance; }
View
1 MongoDB.Bson/Serialization/Serializers/VersionSerializer.cs
@@ -45,6 +45,7 @@ public VersionSerializer()
/// <summary>
/// Gets an instance of the VersionSerializer class.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static VersionSerializer Instance
{
get { return __instance; }
View
3 MongoDB.Driver/Linq/Translators/PredicateTranslator.cs
@@ -469,7 +469,8 @@ private IMongoQuery BuildContainsKeyQuery(MethodCallExpression methodCallExpress
var key = constantExpression.Value;
var serializationInfo = _serializationInfoHelper.GetSerializationInfo(methodCallExpression.Object);
- var dictionarySerializationOptions = (DictionarySerializationOptions)serializationInfo.SerializationOptions ?? DictionarySerializationOptions.Defaults;
+ var serializer = serializationInfo.Serializer;
+ var dictionarySerializationOptions = (DictionarySerializationOptions)(serializationInfo.SerializationOptions ?? serializer.GetDefaultSerializationOptions());
var keyActualType = (key != null) ? key.GetType() : keyNominalType;
var keySerializer = BsonSerializer.LookupSerializer(keyActualType);
View
4 MongoDB.Driver/MongoDBRef.cs
@@ -268,12 +268,12 @@ public BsonSerializationInfo GetMemberSerializationInfo(string memberName)
{
case "DatabaseName":
elementName = "$db";
- serializer = StringSerializer.Instance;
+ serializer = new StringSerializer();
nominalType = typeof(string);
break;
case "CollectionName":
elementName = "$ref";
- serializer = StringSerializer.Instance;
+ serializer = new StringSerializer();
nominalType = typeof(string);
break;
case "Id":
View
79 MongoDB.Driver/SystemProfileInfo.cs
@@ -48,7 +48,7 @@ public SystemProfileInfo()
/// </summary>
/// <param name="backingDocument">The backing document.</param>
internal SystemProfileInfo(BsonDocument backingDocument)
- : base(backingDocument, SystemProfileInfoSerializer.Instance)
+ : base(backingDocument, new SystemProfileInfoSerializer())
{ }
// public properties
@@ -369,7 +369,7 @@ public SystemProfileLockStatistics()
/// </summary>
/// <param name="backingDocument">The backing document.</param>
internal SystemProfileLockStatistics(BsonDocument backingDocument)
- : base(backingDocument, SystemProfileLockStatisticsSerializer.Instance)
+ : base(backingDocument, new SystemProfileLockStatisticsSerializer())
{ }
// public properties
@@ -420,7 +420,7 @@ public SystemProfileReadWriteLockStatistics()
/// </summary>
/// <param name="backingDocument">The backing document.</param>
internal SystemProfileReadWriteLockStatistics(BsonDocument backingDocument)
- : base(backingDocument, SystemProfileReadWriteLockStatisticsSerializer.Instance)
+ : base(backingDocument, new SystemProfileReadWriteLockStatisticsSerializer())
{ }
// public properties
@@ -503,44 +503,45 @@ public class SystemProfileInfoSerializer : BsonDocumentBackedClassSerializer<Sys
/// </summary>
public SystemProfileInfoSerializer()
{
- RegisterMember("Abbreviated", "abbreviated", StringSerializer.Instance, typeof(string), null);
- RegisterMember("Client", "client", StringSerializer.Instance, typeof(string), null);
+ RegisterMember("Abbreviated", "abbreviated", new StringSerializer(), typeof(string), null);
+ RegisterMember("Client", "client", new StringSerializer(), typeof(string), null);
RegisterMember("Command", "command", BsonDocumentSerializer.Instance, typeof(BsonDocument), null);
- RegisterMember("CursorId", "cursorid", Int64Serializer.Instance, typeof(long), null);
- RegisterMember("Duration", "millis", TimeSpanSerializer.Instance, typeof(TimeSpan), new TimeSpanSerializationOptions(BsonType.Double, TimeSpanUnits.Milliseconds));
- RegisterMember("Error", "err", StringSerializer.Instance, typeof(string), null);
- RegisterMember("Exception", "exception", StringSerializer.Instance, typeof(string), null);
- RegisterMember("ExceptionCode", "exceptionCode", Int32Serializer.Instance, typeof(int), null);
- RegisterMember("Exhaust", "exhaust", BooleanSerializer.Instance, typeof(bool), null);
- RegisterMember("FastMod", "fastmod", BooleanSerializer.Instance, typeof(bool), null);
- RegisterMember("FastModInsert", "fastmodinsert", BooleanSerializer.Instance, typeof(bool), null);
- RegisterMember("IdHack", "idhack", BooleanSerializer.Instance, typeof(bool), null);
- RegisterMember("Info", "info", StringSerializer.Instance, typeof(string), null);
- RegisterMember("KeyUpdates", "keyUpdates", Int32Serializer.Instance, typeof(int), null);
- RegisterMember("LockStatistics", "lockStats", SystemProfileLockStatisticsSerializer.Instance, typeof(SystemProfileLockStatistics), null);
- RegisterMember("Moved", "moved", BooleanSerializer.Instance, typeof(bool), null);
- RegisterMember("Namespace", "ns", StringSerializer.Instance, typeof(string), null);
- RegisterMember("NumberMoved", "nmoved", Int32Serializer.Instance, typeof(int), null);
- RegisterMember("NumberReturned", "nreturned", Int32Serializer.Instance, typeof(int), null);
- RegisterMember("NumberScanned", "nscanned", Int32Serializer.Instance, typeof(int), null);
- RegisterMember("NumberToReturn", "ntoreturn", Int32Serializer.Instance, typeof(int), null);
- RegisterMember("NumberToSkip", "ntoskip", Int32Serializer.Instance, typeof(int), null);
- RegisterMember("NumberUpdated", "nupdated", Int32Serializer.Instance, typeof(int), null);
- RegisterMember("NumberOfYields", "numYield", Int32Serializer.Instance, typeof(int), null);
- RegisterMember("Op", "op", StringSerializer.Instance, typeof(string), null);
+ RegisterMember("CursorId", "cursorid", new Int64Serializer(), typeof(long), null);
+ RegisterMember("Duration", "millis", new TimeSpanSerializer(), typeof(TimeSpan), new TimeSpanSerializationOptions(BsonType.Double, TimeSpanUnits.Milliseconds));
+ RegisterMember("Error", "err", new StringSerializer(), typeof(string), null);
+ RegisterMember("Exception", "exception", new StringSerializer(), typeof(string), null);
+ RegisterMember("ExceptionCode", "exceptionCode", new Int32Serializer(), typeof(int), null);
+ RegisterMember("Exhaust", "exhaust", new BooleanSerializer(), typeof(bool), null);
+ RegisterMember("FastMod", "fastmod", new BooleanSerializer(), typeof(bool), null);
+ RegisterMember("FastModInsert", "fastmodinsert", new BooleanSerializer(), typeof(bool), null);
+ RegisterMember("IdHack", "idhack", new BooleanSerializer(), typeof(bool), null);
+ RegisterMember("Info", "info", new StringSerializer(), typeof(string), null);
+ RegisterMember("KeyUpdates", "keyUpdates", new Int32Serializer(), typeof(int), null);
+ RegisterMember("LockStatistics", "lockStats", new SystemProfileLockStatisticsSerializer(), typeof(SystemProfileLockStatistics), null);
+ RegisterMember("Moved", "moved", new BooleanSerializer(), typeof(bool), null);
+ RegisterMember("Namespace", "ns", new StringSerializer(), typeof(string), null);
+ RegisterMember("NumberMoved", "nmoved", new Int32Serializer(), typeof(int), null);
+ RegisterMember("NumberReturned", "nreturned", new Int32Serializer(), typeof(int), null);
+ RegisterMember("NumberScanned", "nscanned", new Int32Serializer(), typeof(int), null);
+ RegisterMember("NumberToReturn", "ntoreturn", new Int32Serializer(), typeof(int), null);
+ RegisterMember("NumberToSkip", "ntoskip", new Int32Serializer(), typeof(int), null);
+ RegisterMember("NumberUpdated", "nupdated", new Int32Serializer(), typeof(int), null);
+ RegisterMember("NumberOfYields", "numYield", new Int32Serializer(), typeof(int), null);
+ RegisterMember("Op", "op", new StringSerializer(), typeof(string), null);
RegisterMember("Query", "query", BsonDocumentSerializer.Instance, typeof(BsonDocument), null);
- RegisterMember("ResponseLength", "responseLength", Int32Serializer.Instance, typeof(int), null);
- RegisterMember("ScanAndOrder", "scanAndOrder", BooleanSerializer.Instance, typeof(bool), null);
- RegisterMember("Timestamp", "ts", DateTimeSerializer.Instance, typeof(DateTime), null);
+ RegisterMember("ResponseLength", "responseLength", new Int32Serializer(), typeof(int), null);
+ RegisterMember("ScanAndOrder", "scanAndOrder", new BooleanSerializer(), typeof(bool), null);
+ RegisterMember("Timestamp", "ts", new DateTimeSerializer(), typeof(DateTime), null);
RegisterMember("UpdateObject", "updateobj", BsonDocumentSerializer.Instance, typeof(BsonDocument), null);
- RegisterMember("Upsert", "upsert", BooleanSerializer.Instance, typeof(bool), null);
- RegisterMember("User", "user", StringSerializer.Instance, typeof(string), null);
+ RegisterMember("Upsert", "upsert", new BooleanSerializer(), typeof(bool), null);
+ RegisterMember("User", "user", new StringSerializer(), typeof(string), null);
}
// public static properties
/// <summary>
/// Gets the instance.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static SystemProfileInfoSerializer Instance
{
get { return __instance; }
@@ -572,14 +573,15 @@ public class SystemProfileLockStatisticsSerializer : BsonDocumentBackedClassSeri
/// </summary>
public SystemProfileLockStatisticsSerializer()
{
- RegisterMember("TimeAcquiring", "timeAcquiringMicros", SystemProfileReadWriteLockStatisticsSerializer.Instance, typeof(SystemProfileReadWriteLockStatistics), null);
- RegisterMember("TimeLocked", "timeLockedMicros", SystemProfileReadWriteLockStatisticsSerializer.Instance, typeof(SystemProfileReadWriteLockStatistics), null);
+ RegisterMember("TimeAcquiring", "timeAcquiringMicros", new SystemProfileReadWriteLockStatisticsSerializer(), typeof(SystemProfileReadWriteLockStatistics), null);
+ RegisterMember("TimeLocked", "timeLockedMicros", new SystemProfileReadWriteLockStatisticsSerializer(), typeof(SystemProfileReadWriteLockStatistics), null);
}
// public static properties
/// <summary>
/// Gets the instance.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static SystemProfileLockStatisticsSerializer Instance
{
get { return __instance; }
@@ -612,16 +614,17 @@ public class SystemProfileReadWriteLockStatisticsSerializer : BsonDocumentBacked
public SystemProfileReadWriteLockStatisticsSerializer()
{
var timeSpanSerializationOptions = new TimeSpanSerializationOptions(BsonType.Double, TimeSpanUnits.Microseconds);
- RegisterMember("DatabaseReadLock", "r", TimeSpanSerializer.Instance, typeof(TimeSpan), timeSpanSerializationOptions);
- RegisterMember("GlobalReadLock", "R", TimeSpanSerializer.Instance, typeof(TimeSpan), timeSpanSerializationOptions);
- RegisterMember("DatabaseWriteLock", "w", TimeSpanSerializer.Instance, typeof(TimeSpan), timeSpanSerializationOptions);
- RegisterMember("GlobalWriteLock", "W", TimeSpanSerializer.Instance, typeof(TimeSpan), timeSpanSerializationOptions);
+ RegisterMember("DatabaseReadLock", "r", new TimeSpanSerializer(), typeof(TimeSpan), timeSpanSerializationOptions);
+ RegisterMember("GlobalReadLock", "R", new TimeSpanSerializer(), typeof(TimeSpan), timeSpanSerializationOptions);
+ RegisterMember("DatabaseWriteLock", "w", new TimeSpanSerializer(), typeof(TimeSpan), timeSpanSerializationOptions);
+ RegisterMember("GlobalWriteLock", "W", new TimeSpanSerializer(), typeof(TimeSpan), timeSpanSerializationOptions);
}
// public static properties
/// <summary>
/// Gets the instance.
/// </summary>
+ [Obsolete("Use constructor instead.")]
public static SystemProfileReadWriteLockStatisticsSerializer Instance
{
get { return __instance; }

0 comments on commit 5dabdce

Please sign in to comment.
Something went wrong with that request. Please try again.