Class ObjectSerializer
- Namespace
- MongoDB.Bson.Serialization.Serializers
- Assembly
- MongoDB.Bson.dll
Represents a serializer for objects.
public class ObjectSerializer : ClassSerializerBase<object>, IBsonSerializer<object>, IBsonSerializer
- Inheritance
-
ObjectSerializer
- Implements
- Inherited Members
- Extension Methods
Constructors
ObjectSerializer()
Initializes a new instance of the ObjectSerializer class.
public ObjectSerializer()
ObjectSerializer(IDiscriminatorConvention)
Initializes a new instance of the ObjectSerializer class.
public ObjectSerializer(IDiscriminatorConvention discriminatorConvention)
Parameters
discriminatorConvention
IDiscriminatorConventionThe discriminator convention.
Exceptions
- ArgumentNullException
discriminatorConvention
ObjectSerializer(IDiscriminatorConvention, GuidRepresentation)
Initializes a new instance of the ObjectSerializer class.
public ObjectSerializer(IDiscriminatorConvention discriminatorConvention, GuidRepresentation guidRepresentation)
Parameters
discriminatorConvention
IDiscriminatorConventionThe discriminator convention.
guidRepresentation
GuidRepresentationThe Guid representation.
ObjectSerializer(IDiscriminatorConvention, GuidRepresentation, Func<Type, bool>)
Initializes a new instance of the ObjectSerializer class.
public ObjectSerializer(IDiscriminatorConvention discriminatorConvention, GuidRepresentation guidRepresentation, Func<Type, bool> allowedTypes)
Parameters
discriminatorConvention
IDiscriminatorConventionThe discriminator convention.
guidRepresentation
GuidRepresentationThe Guid representation.
allowedTypes
Func<Type, bool>A delegate that determines what types are allowed.
ObjectSerializer(IDiscriminatorConvention, GuidRepresentation, Func<Type, bool>, Func<Type, bool>)
Initializes a new instance of the ObjectSerializer class.
public ObjectSerializer(IDiscriminatorConvention discriminatorConvention, GuidRepresentation guidRepresentation, Func<Type, bool> allowedDeserializationTypes, Func<Type, bool> allowedSerializationTypes)
Parameters
discriminatorConvention
IDiscriminatorConventionThe discriminator convention.
guidRepresentation
GuidRepresentationThe Guid representation.
allowedDeserializationTypes
Func<Type, bool>A delegate that determines what types are allowed to be deserialized.
allowedSerializationTypes
Func<Type, bool>A delegate that determines what types are allowed to be serialized.
ObjectSerializer(IDiscriminatorConvention, Func<Type, bool>)
Initializes a new instance of the ObjectSerializer class.
public ObjectSerializer(IDiscriminatorConvention discriminatorConvention, Func<Type, bool> allowedTypes)
Parameters
discriminatorConvention
IDiscriminatorConventionThe discriminator convention.
allowedTypes
Func<Type, bool>A delegate that determines what types are allowed.
ObjectSerializer(Func<Type, bool>)
Initializes a new instance of the ObjectSerializer class.
public ObjectSerializer(Func<Type, bool> allowedTypes)
Parameters
Properties
AllAllowedTypes
An allowed types function that returns true for all types.
public static Func<Type, bool> AllAllowedTypes { get; }
Property Value
AllowedDeserializationTypes
Gets the AllowedDeserializationTypes filter;
public Func<Type, bool> AllowedDeserializationTypes { get; }
Property Value
AllowedSerializationTypes
Gets the AllowedSerializationTypes filter;
public Func<Type, bool> AllowedSerializationTypes { get; }
Property Value
DefaultAllowedTypes
An allowed types function that returns true for framework types known to be safe.
public static Func<Type, bool> DefaultAllowedTypes { get; }
Property Value
DiscriminatorConvention
Gets the discriminator convention.
public IDiscriminatorConvention DiscriminatorConvention { get; }
Property Value
GuidRepresentation
Gets the GuidRepresentation.
public GuidRepresentation GuidRepresentation { get; }
Property Value
Instance
Gets the standard instance.
public static ObjectSerializer Instance { get; }
Property Value
NoAllowedTypes
An allowed types function that returns false for all types.
public static Func<Type, bool> NoAllowedTypes { get; }
Property Value
Methods
Deserialize(BsonDeserializationContext, BsonDeserializationArgs)
Deserializes a value.
public override object Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
Parameters
context
BsonDeserializationContextThe deserialization context.
args
BsonDeserializationArgsThe deserialization args.
Returns
- object
A deserialized value.
Equals(object)
public override bool Equals(object obj)
Parameters
obj
object
Returns
GetHashCode()
public override int GetHashCode()
Returns
Serialize(BsonSerializationContext, BsonSerializationArgs, object)
Serializes a value.
public override void Serialize(BsonSerializationContext context, BsonSerializationArgs args, object value)
Parameters
context
BsonSerializationContextThe serialization context.
args
BsonSerializationArgsThe serialization args.
value
objectThe object.
WithDiscriminatorConvention(IDiscriminatorConvention)
Returns a new ObjectSerializer configured the same but with the specified discriminator convention.
public ObjectSerializer WithDiscriminatorConvention(IDiscriminatorConvention discriminatorConvention)
Parameters
discriminatorConvention
IDiscriminatorConventionThe discriminator convention.
Returns
- ObjectSerializer
An ObjectSerializer with the specified discriminator convention.