Skip to content

Commit 8428628

Browse files
author
rstam
committed
Merged refactoring that renamed BsonDefaultSerializer to BsonDefaultSerializationProvider.
1 parent a84681b commit 8428628

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

Bson/Serialization/BsonClassMapSerializationProvider.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
using System;
1+
/* Copyright 2010-2012 10gen 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+
16+
using System;
217
using System.Collections.Generic;
318
using System.Linq;
419
using System.Text;
@@ -28,4 +43,4 @@ public IBsonSerializer GetSerializer(Type type)
2843
return null;
2944
}
3045
}
31-
}
46+
}

Bson/Serialization/BsonDefaultSerializationProvider.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,10 @@
1919
using System.Collections.ObjectModel;
2020
using System.Collections.Specialized;
2121
using System.Drawing;
22-
using System.Drawing.Imaging;
2322
using System.Globalization;
24-
using System.IO;
2523
using System.Linq;
2624
using System.Net;
27-
using System.Reflection;
28-
using System.Text;
29-
using System.Text.RegularExpressions;
3025

31-
using MongoDB.Bson.IO;
32-
using MongoDB.Bson.Serialization.Attributes;
33-
using MongoDB.Bson.Serialization.Conventions;
3426
using MongoDB.Bson.Serialization.Serializers;
3527

3628
namespace MongoDB.Bson.Serialization
@@ -41,7 +33,6 @@ namespace MongoDB.Bson.Serialization
4133
internal class BsonDefaultSerializationProvider : IBsonSerializationProvider
4234
{
4335
// private static fields
44-
private static BsonDefaultSerializationProvider __instance = new BsonDefaultSerializationProvider();
4536
private static Dictionary<Type, IBsonSerializer> __serializers;
4637
private static Dictionary<Type, Type> __genericSerializerDefinitions;
4738

Bson/Serialization/BsonSerializer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static class BsonSerializer
5050
// static constructor
5151
static BsonSerializer()
5252
{
53-
RegisterDefaultSerializationProvider();
53+
RegisterDefaultSerializationProviders();
5454
RegisterIdGenerators();
5555
}
5656

@@ -834,7 +834,7 @@ internal static void EnsureKnownTypesAreRegistered(Type nominalType)
834834
var knownTypesAttribute = nominalType.GetCustomAttributes(typeof(BsonKnownTypesAttribute), false);
835835
if (knownTypesAttribute != null && knownTypesAttribute.Length > 0)
836836
{
837-
//try and force a scan of the known types
837+
// try and force a scan of the known types
838838
LookupSerializer(nominalType);
839839
}
840840

@@ -848,9 +848,9 @@ internal static void EnsureKnownTypesAreRegistered(Type nominalType)
848848
}
849849

850850
// private static methods
851-
private static void RegisterDefaultSerializationProvider()
851+
private static void RegisterDefaultSerializationProviders()
852852
{
853-
//These are run in reverse order.
853+
// last one registered gets first chance at providing the serializer
854854
RegisterSerializationProvider(new BsonClassMapSerializationProvider());
855855
RegisterSerializationProvider(new BsonDefaultSerializationProvider());
856856
}

0 commit comments

Comments
 (0)