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
-
JsonConverterJsonConverter<Person>PersonConverter
- Implements
-
IBsonSerializer
- Inherited Members
-
JsonConverter.CanReadJsonConverter.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
valueTypeType
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
contextBsonDeserializationContextThe BSON deserialization context.
argsBsonDeserializationArgsThe 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
readerJsonReaderThe Newtonsoft.Json.JsonReader to read from.
objectTypeTypeThe type of the object to deserialize.
existingValuePersonThe existing value of the object being read, or
nullif there is no existing value.hasExistingValueboolA value indicating whether
existingValuehas a value.serializerJsonSerializerThe Newtonsoft.Json.JsonSerializer calling the method.
Returns
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
contextBsonSerializationContextThe BSON serialization context that provides the writer and configuration for the operation.
argsBsonSerializationArgsThe BSON serialization arguments containing additional settings for the serialization.
valueobjectThe 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
writerJsonWriterThe Newtonsoft.Json.JsonWriter to which the JSON representation is written.
valuePersonThe Person instance to serialize. If null, the method returns without writing anything.
serializerJsonSerializerThe Newtonsoft.Json.JsonSerializer used during the conversion to a Newtonsoft.Json.Linq.JObject.