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
BsonClassMapThe class map this member map belongs to.
memberInfo
MemberInfoThe member info.
Properties
ClassMap
Gets the class map that this member map belongs to.
public BsonClassMap ClassMap { get; }
Property Value
DefaultValue
Gets the default value.
public object DefaultValue { get; }
Property Value
ElementName
Gets the name of the element.
public string ElementName { get; }
Property Value
Getter
Gets the getter function.
public Func<object, object> Getter { get; }
Property Value
IdGenerator
Gets the Id generator.
public IIdGenerator IdGenerator { get; }
Property Value
IgnoreIfDefault
Gets whether default values should be ignored when serialized.
public bool IgnoreIfDefault { get; }
Property Value
IgnoreIfNull
Gets whether null values should be ignored when serialized.
public bool IgnoreIfNull { get; }
Property Value
IsDefaultValueSpecified
Gets whether a default value was specified.
public bool IsDefaultValueSpecified { get; }
Property Value
IsReadOnly
Gets whether the member is readonly.
public bool IsReadOnly { get; }
Property Value
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
MemberInfo
Gets the member info.
public MemberInfo MemberInfo { get; }
Property Value
MemberName
Gets the name of the member.
public string MemberName { get; }
Property Value
MemberType
Gets the type of the member.
public Type MemberType { get; }
Property Value
MemberTypeIsBsonValue
Gets whether the member type is a BsonValue.
public bool MemberTypeIsBsonValue { get; }
Property Value
Order
Gets the serialization order.
public int Order { get; }
Property Value
Setter
Gets the setter function.
public Action<object, object> Setter { get; }
Property Value
ShouldSerializeMethod
Gets the method that will be called to determine whether the member should be serialized.
public Func<object, bool> ShouldSerializeMethod { get; }
Property Value
Methods
ApplyDefaultValue(object)
Applies the default value to the member of an object.
public void ApplyDefaultValue(object obj)
Parameters
obj
objectThe 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
objectThe default value.
Returns
- BsonMemberMap
The member map.
SetElementName(string)
Sets the name of the element.
public BsonMemberMap SetElementName(string elementName)
Parameters
elementName
stringThe name of the element.
Returns
- BsonMemberMap
The member map.
SetIdGenerator(IIdGenerator)
Sets the Id generator.
public BsonMemberMap SetIdGenerator(IIdGenerator idGenerator)
Parameters
idGenerator
IIdGeneratorThe 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
boolWhether 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
boolWether 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
boolWhether 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
intThe serialization order.
Returns
- BsonMemberMap
The member map.
SetSerializer(IBsonSerializer)
Sets the serializer.
public BsonMemberMap SetSerializer(IBsonSerializer serializer)
Parameters
serializer
IBsonSerializerThe 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
Returns
- BsonMemberMap
The member map.
ShouldSerialize(object, object)
Determines whether a value should be serialized
public bool ShouldSerialize(object obj, object value)
Parameters
Returns
- bool
True if the value should be serialized.