Table of Contents

Class BsonSerializationInfo

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

Represents the information needed to serialize a member.

public class BsonSerializationInfo
Inheritance
BsonSerializationInfo
Inherited Members
Extension Methods

Constructors

BsonSerializationInfo(string, IBsonSerializer, Type)

Initializes a new instance of the BsonSerializationInfo class.

public BsonSerializationInfo(string elementName, IBsonSerializer serializer, Type nominalType)

Parameters

elementName string

The element name.

serializer IBsonSerializer

The serializer.

nominalType Type

The nominal type.

Properties

ElementName

Gets the element name.

public string ElementName { get; }

Property Value

string

ElementPath

Gets element path.

public IReadOnlyList<string> ElementPath { get; }

Property Value

IReadOnlyList<string>

NominalType

Gets or sets the nominal type.

public Type NominalType { get; }

Property Value

Type

Serializer

Gets or sets the serializer.

public IBsonSerializer Serializer { get; }

Property Value

IBsonSerializer

Methods

CreateWithPath(IEnumerable<string>, IBsonSerializer, Type)

Creates a new instance of the BsonSerializationinfo class with an element path instead of an element name.

public static BsonSerializationInfo CreateWithPath(IEnumerable<string> elementPath, IBsonSerializer serializer, Type nominalType)

Parameters

elementPath IEnumerable<string>

The element path.

serializer IBsonSerializer

The serializer.

nominalType Type

The nominal type.

Returns

BsonSerializationInfo

A BsonSerializationInfo.

DeserializeValue(BsonValue)

Deserializes the value.

public object DeserializeValue(BsonValue value)

Parameters

value BsonValue

The value.

Returns

object

A deserialized value.

Merge(BsonSerializationInfo)

Merges the new BsonSerializationInfo by taking its properties and concatenating its ElementName.

[Obsolete("This method is no longer relevant because field names are now allowed to contain dots.")]
public BsonSerializationInfo Merge(BsonSerializationInfo newSerializationInfo)

Parameters

newSerializationInfo BsonSerializationInfo

The new info.

Returns

BsonSerializationInfo

A new BsonSerializationInfo.

SerializeValue(object)

Serializes the value.

public BsonValue SerializeValue(object value)

Parameters

value object

The value.

Returns

BsonValue

The serialized value.

SerializeValues(IEnumerable)

Serializes the values.

public BsonArray SerializeValues(IEnumerable values)

Parameters

values IEnumerable

The values.

Returns

BsonArray

The serialized values.

WithNewName(string)

Creates a new BsonSerializationInfo object using the elementName provided and copying all other attributes.

public BsonSerializationInfo WithNewName(string elementName)

Parameters

elementName string

Name of the element.

Returns

BsonSerializationInfo

A new BsonSerializationInfo.