Table of Contents

Class PersonConverter

Namespace
adas_core.Infrastructure.Utils
Assembly
adas-core.Infrastructure.dll

Provides JSON conversion for the Person type via Newtonsoft.Json.JsonConverter<T> and also implements BSON serialization through MongoDB.Bson.Serialization.IBsonSerializer.

public class PersonConverter : JsonConverter<Person>, IBsonSerializer
Inheritance
JsonConverter
JsonConverter<Person>
PersonConverter
Implements
IBsonSerializer
Inherited Members
JsonConverter.CanRead
JsonConverter.CanWrite
Extension Methods

Remarks

The primary constructor accepts a Type that represents the value type associated with this converter.

Constructors

PersonConverter(Type)

Provides JSON conversion for the Person type via Newtonsoft.Json.JsonConverter<T> and also implements BSON serialization through MongoDB.Bson.Serialization.IBsonSerializer.

public PersonConverter(Type valueType)

Parameters

valueType Type

Remarks

The primary constructor accepts a Type that represents the value type associated with this converter.

Properties

ValueType

Gets the type of the value.

public Type ValueType { get; }

Property Value

Type

The type of the value.

Methods

Deserialize(BsonDeserializationContext, BsonDeserializationArgs)

Deserializes a BSON value into a .NET object using the provided context and arguments.

public object Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)

Parameters

context BsonDeserializationContext

The BSON deserialization context.

args BsonDeserializationArgs

The BSON deserialization arguments.

Returns

object

The deserialized object.

Exceptions

NotImplementedException

Always thrown because the method is not yet implemented.

ReadJson(JsonReader, Type, Person?, bool, JsonSerializer)

Reads the JSON representation of a Person object. This override is not yet implemented.

public override Person ReadJson(JsonReader reader, Type objectType, Person? existingValue, bool hasExistingValue, JsonSerializer serializer)

Parameters

reader JsonReader

The Newtonsoft.Json.JsonReader to read from.

objectType Type

The type of the object to deserialize.

existingValue Person

The existing value of the object being read, or null if there is no existing value.

hasExistingValue bool

A value indicating whether existingValue has a value.

serializer JsonSerializer

The Newtonsoft.Json.JsonSerializer calling the method.

Returns

Person

A Person instance deserialized from the JSON.

Exceptions

NotImplementedException

Always thrown because the method has not been implemented.

Serialize(BsonSerializationContext, BsonSerializationArgs, object)

Serializes the specified object to BSON format using the provided serialization context and arguments. The method is not implemented and always throws an exception.

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

Parameters

context BsonSerializationContext

The BSON serialization context that provides the writer and configuration for the operation.

args BsonSerializationArgs

The BSON serialization arguments containing additional settings for the serialization.

value object

The object to be serialized to BSON.

Exceptions

NotImplementedException

Always thrown because the method has not been implemented yet.

WriteJson(JsonWriter, Person?, JsonSerializer)

Serializes a Person instance to JSON, ensuring the Gender property is written using string-based enum representation. Does nothing when the provided value is null.

public override void WriteJson(JsonWriter writer, Person? value, JsonSerializer serializer)

Parameters

writer JsonWriter

The Newtonsoft.Json.JsonWriter to which the JSON representation is written.

value Person

The Person instance to serialize. If null, the method returns without writing anything.

serializer JsonSerializer

The Newtonsoft.Json.JsonSerializer used during the conversion to a Newtonsoft.Json.Linq.JObject.