Permalink
Browse files

Minor renaming and doc comment fixes.

  • Loading branch information...
1 parent 1ad2875 commit e99951f04c65787b343e1ca141e2df38b507e9d8 rstam committed Mar 14, 2012
View
@@ -282,6 +282,7 @@ public string FindStringElement(string name)
/// <summary>
/// Gets the current BsonType (calls ReadBsonType if necessary).
/// </summary>
+ /// <returns>The current BsonType.</returns>
public BsonType GetCurrentBsonType()
{
if (_state == BsonReaderState.Initial || _state == BsonReaderState.Done || _state == BsonReaderState.ScopeDocument || _state == BsonReaderState.Type)
@@ -39,6 +39,7 @@ public class BsonClassMapSerializer : IBsonSerializer
/// <summary>
/// Initializes a new instance of the BsonClassMapSerializer class.
/// </summary>
+ /// <param name="classMap">The class map.</param>
public BsonClassMapSerializer(BsonClassMap classMap)
{
_classMap = classMap;
@@ -291,7 +292,7 @@ public BsonSerializationInfo GetMemberSerializationInfo(string memberName)
if (documentSerializationOptions == null)
{
var message = string.Format(
- "Serialize method of BsonDocument expected serialization options of type {0}, not {1}.",
+ "Serializer BsonClassMapSerializer expected serialization options of type {0}, not {1}.",
BsonUtils.GetFriendlyTypeName(typeof(DocumentSerializationOptions)),
BsonUtils.GetFriendlyTypeName(options.GetType()));
throw new BsonSerializationException(message);
@@ -133,7 +133,7 @@ public override BsonSerializationInfo GetItemSerializationInfo()
}
var array = (T[])value;
- var arraySerializationOptions = CastSerializationOptions<ArraySerializationOptions>(options);
+ var arraySerializationOptions = EnsureSerializationOptions<ArraySerializationOptions>(options);
var itemSerializationOptions = arraySerializationOptions.ItemSerializationOptions;
bsonWriter.WriteStartArray();
@@ -266,7 +266,7 @@ public TwoDimensionalArraySerializer()
}
var array = (T[,])value;
- var arraySerializationOptions = CastSerializationOptions<ArraySerializationOptions>(options);
+ var arraySerializationOptions = EnsureSerializationOptions<ArraySerializationOptions>(options);
var itemSerializationOptions = arraySerializationOptions.ItemSerializationOptions;
bsonWriter.WriteStartArray();
@@ -423,7 +423,7 @@ public ThreeDimensionalArraySerializer()
}
var array = (T[, ,])value;
- var arraySerializationOptions = CastSerializationOptions<ArraySerializationOptions>(options);
+ var arraySerializationOptions = EnsureSerializationOptions<ArraySerializationOptions>(options);
var itemSerializationOptions = arraySerializationOptions.ItemSerializationOptions;
bsonWriter.WriteStartArray();
@@ -45,6 +45,7 @@ protected BsonBaseSerializer()
/// <summary>
/// Initializes a new instance of the BsonBaseSerializer class.
/// </summary>
+ /// <param name="defaultSerializationOptions">The default serialization options for this serializer.</param>
protected BsonBaseSerializer(IBsonSerializationOptions defaultSerializationOptions)
{
if (defaultSerializationOptions != null)
@@ -168,12 +169,12 @@ public virtual void SetDocumentId(object document, object id)
// protected methods
/// <summary>
- /// Casts the provided serialization options (or the defaults if null) to the required type.
+ /// Ensures that the serializer has serialization options of the right type (replacing null with the default serialization options if necessary).
/// </summary>
/// <typeparam name="TSerializationOptions">The required serialization options type.</typeparam>
/// <param name="options">The serialization options.</param>
/// <returns>The serialization options (or the defaults if null) cast to the required type.</returns>
- protected TSerializationOptions CastSerializationOptions<TSerializationOptions>(IBsonSerializationOptions options) where TSerializationOptions : class, IBsonSerializationOptions
+ protected TSerializationOptions EnsureSerializationOptions<TSerializationOptions>(IBsonSerializationOptions options) where TSerializationOptions : class, IBsonSerializationOptions
{
if (options == null)
{
@@ -107,7 +107,7 @@ public static BooleanSerializer Instance
IBsonSerializationOptions options)
{
var boolValue = (bool)value;
- var representationSerializationOptions = CastSerializationOptions<RepresentationSerializationOptions>(options);
+ var representationSerializationOptions = EnsureSerializationOptions<RepresentationSerializationOptions>(options);
switch (representationSerializationOptions.Representation)
{
@@ -175,7 +175,7 @@ public static DateTimeSerializer Instance
IBsonSerializationOptions options)
{
VerifyTypes(nominalType, actualType, typeof(DateTime));
- var dateTimeSerializationOptions = CastSerializationOptions<DateTimeSerializationOptions>(options);
+ var dateTimeSerializationOptions = EnsureSerializationOptions<DateTimeSerializationOptions>(options);
var bsonType = bsonReader.GetCurrentBsonType();
DateTime value;
@@ -250,7 +250,7 @@ public static DateTimeSerializer Instance
IBsonSerializationOptions options)
{
var dateTime = (DateTime)value;
- var dateTimeSerializationOptions = CastSerializationOptions<DateTimeSerializationOptions>(options);
+ var dateTimeSerializationOptions = EnsureSerializationOptions<DateTimeSerializationOptions>(options);
DateTime utcDateTime;
if (dateTimeSerializationOptions.DateOnly)
@@ -351,7 +351,7 @@ public static DoubleSerializer Instance
IBsonSerializationOptions options)
{
VerifyTypes(nominalType, actualType, typeof(double));
- var representationSerializationOptions = CastSerializationOptions<RepresentationSerializationOptions>(options);
+ var representationSerializationOptions = EnsureSerializationOptions<RepresentationSerializationOptions>(options);
var bsonType = bsonReader.GetCurrentBsonType();
switch (bsonType)
@@ -384,7 +384,7 @@ public static DoubleSerializer Instance
IBsonSerializationOptions options)
{
var doubleValue = (double)value;
- var representationSerializationOptions = CastSerializationOptions<RepresentationSerializationOptions>(options);
+ var representationSerializationOptions = EnsureSerializationOptions<RepresentationSerializationOptions>(options);
switch (representationSerializationOptions.Representation)
{
@@ -496,7 +496,7 @@ public static GuidSerializer Instance
IBsonSerializationOptions options)
{
var guid = (Guid)value;
- var representationSerializationOptions = CastSerializationOptions<RepresentationSerializationOptions>(options);
+ var representationSerializationOptions = EnsureSerializationOptions<RepresentationSerializationOptions>(options);
switch (representationSerializationOptions.Representation)
{
@@ -562,7 +562,7 @@ public static Int32Serializer Instance
IBsonSerializationOptions options)
{
VerifyTypes(nominalType, actualType, typeof(int));
- var representationSerializationOptions = CastSerializationOptions<RepresentationSerializationOptions>(options);
+ var representationSerializationOptions = EnsureSerializationOptions<RepresentationSerializationOptions>(options);
var bsonType = bsonReader.GetCurrentBsonType();
switch (bsonType)
@@ -595,7 +595,7 @@ public static Int32Serializer Instance
IBsonSerializationOptions options)
{
var int32Value = (int)value;
- var representationSerializationOptions = CastSerializationOptions<RepresentationSerializationOptions>(options);
+ var representationSerializationOptions = EnsureSerializationOptions<RepresentationSerializationOptions>(options);
switch (representationSerializationOptions.Representation)
{
@@ -660,7 +660,7 @@ public static Int64Serializer Instance
IBsonSerializationOptions options)
{
VerifyTypes(nominalType, actualType, typeof(long));
- var representationSerializationOptions = CastSerializationOptions<RepresentationSerializationOptions>(options);
+ var representationSerializationOptions = EnsureSerializationOptions<RepresentationSerializationOptions>(options);
var bsonType = bsonReader.GetCurrentBsonType();
switch (bsonType)
@@ -693,7 +693,7 @@ public static Int64Serializer Instance
IBsonSerializationOptions options)
{
var int64Value = (long)value;
- var representationSerializationOptions = CastSerializationOptions<RepresentationSerializationOptions>(options);
+ var representationSerializationOptions = EnsureSerializationOptions<RepresentationSerializationOptions>(options);
switch (representationSerializationOptions.Representation)
{
@@ -348,7 +348,7 @@ public static BsonDateTimeSerializer Instance
}
else
{
- var dateTimeSerializationOptions = CastSerializationOptions<DateTimeSerializationOptions>(options);
+ var dateTimeSerializationOptions = EnsureSerializationOptions<DateTimeSerializationOptions>(options);
long? millisecondsSinceEpoch = null;
long? ticks = null;
@@ -459,7 +459,7 @@ public static BsonDateTimeSerializer Instance
else
{
var bsonDateTime = (BsonDateTime)value;
- var dateTimeSerializationOptions = CastSerializationOptions<DateTimeSerializationOptions>(options);
+ var dateTimeSerializationOptions = EnsureSerializationOptions<DateTimeSerializationOptions>(options);
DateTime utcDateTime = DateTime.MinValue;
long millisecondsSinceEpoch;
@@ -1673,7 +1673,7 @@ public static BsonSymbolSerializer Instance
else
{
var symbol = (BsonSymbol)value;
- var representationSerializationOptions = CastSerializationOptions<RepresentationSerializationOptions>(options);
+ var representationSerializationOptions = EnsureSerializationOptions<RepresentationSerializationOptions>(options);
switch (representationSerializationOptions.Representation)
{
@@ -228,7 +228,7 @@ public override BsonSerializationInfo GetItemSerializationInfo()
}
var dictionary = (IDictionary<TKey, TValue>)value;
- var dictionarySerializationOptions = CastSerializationOptions<DictionarySerializationOptions>(options);
+ var dictionarySerializationOptions = EnsureSerializationOptions<DictionarySerializationOptions>(options);
var representation = dictionarySerializationOptions.Representation;
var itemSerializationOptions = dictionarySerializationOptions.ItemSerializationOptions;
@@ -238,7 +238,7 @@ public override BsonSerializationInfo GetItemSerializationInfo()
}
var dictionary = (IDictionary)value;
- var dictionarySerializationOptions = CastSerializationOptions<DictionarySerializationOptions>(options);
+ var dictionarySerializationOptions = EnsureSerializationOptions<DictionarySerializationOptions>(options);
var representation = dictionarySerializationOptions.Representation;
var itemSerializationOptions = dictionarySerializationOptions.ItemSerializationOptions;
@@ -39,7 +39,7 @@ public class EnumSerializer : BsonBaseSerializer
/// Initializes a new instance of the EnumSerializer class.
/// </summary>
public EnumSerializer()
- : base(new RepresentationSerializationOptions((BsonType)0))
+ : base(new RepresentationSerializationOptions((BsonType)0)) // 0 means use underlying type
{
}
@@ -94,7 +94,7 @@ public static EnumSerializer Instance
var actualType = value.GetType();
VerifySerializeTypes(nominalType, actualType);
- var representationSerializationOptions = CastSerializationOptions<RepresentationSerializationOptions>(options);
+ var representationSerializationOptions = EnsureSerializationOptions<RepresentationSerializationOptions>(options);
switch (representationSerializationOptions.Representation)
{
Oops, something went wrong.

0 comments on commit e99951f

Please sign in to comment.