# Class ComplexObjectValueTypeSerializer

Namespace
  adas_core.Domain.Utils

Assembly
  adas-core.Domain.dll

Represents a serializer for complex object value types, deriving from MongoDB.Bson.Serialization.Serializers.SerializerBase<TValue> with object as the type argument.

    public class ComplexObjectValueTypeSerializer : SerializerBase<object>, IBsonSerializer<object>, IBsonSerializer

Inheritance
  object
  SerializerBase<object>
  ComplexObjectValueTypeSerializer

Implements
  IBsonSerializer<object>
  IBsonSerializer

Inherited Members
  SerializerBase<object>.Equals(object)
  SerializerBase<object>.GetHashCode()
  SerializerBase<object>.CreateCannotBeDeserializedException()
  SerializerBase<object>.CreateCannotBeSerializedException()
  SerializerBase<object>.CreateCannotDeserializeFromBsonTypeException(BsonType)
  SerializerBase<object>.EnsureBsonTypeEquals(IBsonReader, BsonType)
  SerializerBase<object>.ValueType
  object.Equals(object, object)
  object.GetType()
  object.MemberwiseClone()
  object.ReferenceEquals(object, object)
  object.ToString()

Extension Methods
  NumberUtils.IsNumber(object)
  NumberUtils.ToDouble(object)
  ObjectUtils.ToStr(object?)

## Remarks

Declared as a partial class, allowing its definition to be split across multiple files.

## Methods

### Deserialize(BsonDeserializationContext, BsonDeserializationArgs)

Deserializes a value.

    public override object Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)

#### Parameters

`context` BsonDeserializationContext

  The deserialization context.

`args` BsonDeserializationArgs

  The deserialization args.

#### Returns

object

  A deserialized value.

### Serialize(BsonSerializationContext, BsonSerializationArgs, object)

Serializes a value of an unknown runtime type into BSON, handling common primitives, OptionList, PatientAllergiesValue, and their list variants directly, and using reflection to dispatch generic MongoDB.Bson.Serialization.Serializers.ArraySerializer<TItem> for arbitrary ICollection instances. For any other type, the value is converted to JSON, parsed into a MongoDB.Bson.BsonDocument, tagged with its full type name in the `_t` field, and then written out.

    public override void Serialize(BsonSerializationContext context, BsonSerializationArgs args, object value)

#### Parameters

`context` BsonSerializationContext

  The BSON serialization context that provides the writer used to emit the serialized output.

`args` BsonSerializationArgs

  Additional BSON serialization arguments passed through to the underlying serializers.

`value` object

  The runtime value to serialize. A `null` value is written as a BSON null; all other values are dispatched based on their concrete type.