Table of Contents

Class BsonMemberMap

Namespace
MongoDB.Bson.Serialization
Assembly
MongoDB.Bson.dll

Represents the mapping between a field or property and a BSON element.

public class BsonMemberMap
Inheritance
BsonMemberMap
Inherited Members
Extension Methods

Constructors

BsonMemberMap(BsonClassMap, MemberInfo)

Initializes a new instance of the BsonMemberMap class.

public BsonMemberMap(BsonClassMap classMap, MemberInfo memberInfo)

Parameters

classMap BsonClassMap

The class map this member map belongs to.

memberInfo MemberInfo

The member info.

Properties

ClassMap

Gets the class map that this member map belongs to.

public BsonClassMap ClassMap { get; }

Property Value

BsonClassMap

DefaultValue

Gets the default value.

public object DefaultValue { get; }

Property Value

object

ElementName

Gets the name of the element.

public string ElementName { get; }

Property Value

string

Getter

Gets the getter function.

public Func<object, object> Getter { get; }

Property Value

Func<object, object>

IdGenerator

Gets the Id generator.

public IIdGenerator IdGenerator { get; }

Property Value

IIdGenerator

IgnoreIfDefault

Gets whether default values should be ignored when serialized.

public bool IgnoreIfDefault { get; }

Property Value

bool

IgnoreIfNull

Gets whether null values should be ignored when serialized.

public bool IgnoreIfNull { get; }

Property Value

bool

IsDefaultValueSpecified

Gets whether a default value was specified.

public bool IsDefaultValueSpecified { get; }

Property Value

bool

IsReadOnly

Gets whether the member is readonly.

public bool IsReadOnly { get; }

Property Value

bool

Remarks

Readonly indicates that the member is written to the database, but not read from the database.

IsRequired

Gets whether an element is required for this member when deserialized.

public bool IsRequired { get; }

Property Value

bool

MemberInfo

Gets the member info.

public MemberInfo MemberInfo { get; }

Property Value

MemberInfo

MemberName

Gets the name of the member.

public string MemberName { get; }

Property Value

string

MemberType

Gets the type of the member.

public Type MemberType { get; }

Property Value

Type

MemberTypeIsBsonValue

Gets whether the member type is a BsonValue.

public bool MemberTypeIsBsonValue { get; }

Property Value

bool

Order

Gets the serialization order.

public int Order { get; }

Property Value

int

Setter

Gets the setter function.

public Action<object, object> Setter { get; }

Property Value

Action<object, object>

ShouldSerializeMethod

Gets the method that will be called to determine whether the member should be serialized.

public Func<object, bool> ShouldSerializeMethod { get; }

Property Value

Func<object, bool>

Methods

ApplyDefaultValue(object)

Applies the default value to the member of an object.

public void ApplyDefaultValue(object obj)

Parameters

obj object

The object.

Freeze()

Freezes this instance.

public void Freeze()

GetSerializer()

Gets the serializer.

public IBsonSerializer GetSerializer()

Returns

IBsonSerializer

The serializer.

Reset()

Resets the member map back to its initial state.

public BsonMemberMap Reset()

Returns

BsonMemberMap

The member map.

SetDefaultValue(Func<object>)

Sets the default value creator.

public BsonMemberMap SetDefaultValue(Func<object> defaultValueCreator)

Parameters

defaultValueCreator Func<object>

The default value creator (note: the supplied delegate must be thread safe).

Returns

BsonMemberMap

The member map.

SetDefaultValue(object)

Sets the default value.

public BsonMemberMap SetDefaultValue(object defaultValue)

Parameters

defaultValue object

The default value.

Returns

BsonMemberMap

The member map.

SetElementName(string)

Sets the name of the element.

public BsonMemberMap SetElementName(string elementName)

Parameters

elementName string

The name of the element.

Returns

BsonMemberMap

The member map.

SetIdGenerator(IIdGenerator)

Sets the Id generator.

public BsonMemberMap SetIdGenerator(IIdGenerator idGenerator)

Parameters

idGenerator IIdGenerator

The Id generator.

Returns

BsonMemberMap

The member map.

SetIgnoreIfDefault(bool)

Sets whether default values should be ignored when serialized.

public BsonMemberMap SetIgnoreIfDefault(bool ignoreIfDefault)

Parameters

ignoreIfDefault bool

Whether default values should be ignored when serialized.

Returns

BsonMemberMap

The member map.

SetIgnoreIfNull(bool)

Sets whether null values should be ignored when serialized.

public BsonMemberMap SetIgnoreIfNull(bool ignoreIfNull)

Parameters

ignoreIfNull bool

Wether null values should be ignored when serialized.

Returns

BsonMemberMap

The member map.

SetIsRequired(bool)

Sets whether an element is required for this member when deserialized

public BsonMemberMap SetIsRequired(bool isRequired)

Parameters

isRequired bool

Whether an element is required for this member when deserialized

Returns

BsonMemberMap

The member map.

SetOrder(int)

Sets the serialization order.

public BsonMemberMap SetOrder(int order)

Parameters

order int

The serialization order.

Returns

BsonMemberMap

The member map.

SetSerializer(IBsonSerializer)

Sets the serializer.

public BsonMemberMap SetSerializer(IBsonSerializer serializer)

Parameters

serializer IBsonSerializer

The serializer.

Returns

BsonMemberMap

The member map.

Exceptions

ArgumentNullException

serializer

ArgumentException

serializer

SetShouldSerializeMethod(Func<object, bool>)

Sets the method that will be called to determine whether the member should be serialized.

public BsonMemberMap SetShouldSerializeMethod(Func<object, bool> shouldSerializeMethod)

Parameters

shouldSerializeMethod Func<object, bool>

The method.

Returns

BsonMemberMap

The member map.

ShouldSerialize(object, object)

Determines whether a value should be serialized

public bool ShouldSerialize(object obj, object value)

Parameters

obj object

The object.

value object

The value.

Returns

bool

True if the value should be serialized.