Class BSONSerializer
Provides serialization/deserialization of types that support direct BSON serialization/deserialization - implement IBSONSerializable/IBSONDeserializable
Inheritance
System.Object
BSONSerializer
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Azos.Serialization.BSON
Assembly: Azos.dll
Syntax
public class BSONSerializer
Constructors
BSONSerializer()
Declaration
public BSONSerializer()
BSONSerializer(IConfigSectionNode)
Declaration
public BSONSerializer(IConfigSectionNode node)
Parameters
Type | Name | Description |
---|---|---|
IConfigSectionNode | node |
BSONSerializer(BSONTypeResolver)
Declaration
public BSONSerializer(BSONTypeResolver resolver)
Parameters
Type | Name | Description |
---|---|---|
BSONTypeResolver | resolver |
Fields
CONFIG_RESOLVER_SECTON
Declaration
public const string CONFIG_RESOLVER_SECTON = "type-resolver"
Field Value
Type | Description |
---|---|
System.String |
DEFAULT_PK_NAME_FIELD
Declaration
public const string DEFAULT_PK_NAME_FIELD = "__id"
Field Value
Type | Description |
---|---|
System.String |
DEFAULT_TYPE_ID_FIELD
Declaration
public const string DEFAULT_TYPE_ID_FIELD = "__t"
Field Value
Type | Description |
---|---|
System.String |
m_Resolver
Declaration
protected BSONTypeResolver m_Resolver
Field Value
Type | Description |
---|---|
BSONTypeResolver |
Properties
Flags
Defines the purpose/level of detail of serialization
Declaration
[Config]
public BSONSerializationFlags Flags { get; set; }
Property Value
Type | Description |
---|---|
BSONSerializationFlags |
PKFieldName
Declaration
[Config("$pk-name")]
public string PKFieldName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
TypeIDFieldName
Returns the name of the field which is used to store type ID, by default DEFAULT_TYPE_ID_FIELD/"__t" is assumed
Declaration
[Config("$type-id-name")]
public string TypeIDFieldName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Methods
AddTypeIDField(BSONDocument, IBSONSerializable, IBSONSerializable, Object, Boolean)
Adds a field named TypeIDFieldName with the type id of the object instance, force=true to emit the field even if it is a known type. Returns true if type id element was added
Declaration
public virtual bool AddTypeIDField(BSONDocument doc, IBSONSerializable parent, IBSONSerializable self, object ctx, bool force = false)
Parameters
Type | Name | Description |
---|---|---|
BSONDocument | doc | |
IBSONSerializable | parent | |
IBSONSerializable | self | |
System.Object | ctx | |
System.Boolean | force |
Returns
Type | Description |
---|---|
System.Boolean |
Deserialize(BSONDocument, IBSONDeserializable)
Deserilizes an instance from BSONDocument. If instance is not pre-allocated (result=null) tries to create a type decorated with BSONSerializableAttribute(guid)
Declaration
public IBSONDeserializable Deserialize(BSONDocument doc, IBSONDeserializable result = null)
Parameters
Type | Name | Description |
---|---|---|
BSONDocument | doc | |
IBSONDeserializable | result |
Returns
Type | Description |
---|---|
IBSONDeserializable |
Serialize(IBSONSerializable, IBSONSerializable)
Serializes an instance directly into BSONDocument
Declaration
public BSONDocument Serialize(IBSONSerializable payload, IBSONSerializable parent = null)
Parameters
Type | Name | Description |
---|---|---|
IBSONSerializable | payload | |
IBSONSerializable | parent |
Returns
Type | Description |
---|---|
BSONDocument |