Firestore API - Interface IFirestoreTypeDiscriminator<T> (4.2.0)

public interface IFirestoreTypeDiscriminator<T>

Reference documentation and code samples for the Firestore API interface IFirestoreTypeDiscriminator

Type discriminator used during deserialization when a value should be deserialized to one of multiple types sharing a common ancestor (typically an abstract class or an interface) based on the document data for the value.

Namespace

Google.Cloud.Firestore

Assembly

Google.Cloud.Firestore.dll

Type Parameter

Name Description
T

The common ancestor type to be deserialized.

Remarks

The use of a type discriminator allows deserialization to be customized in a single aspect while still using FirestoreDataAttribute etc for the majority of deserialization. The type discriminator needs to be registered in a ConverterRegistry using Add<T>(IFirestoreTypeDiscriminator<T>) when constructing a FirestoreDb via a FirestoreDbBuilder. The type discriminator will be used automatically when deserializing to type T, either directly (e.g. with ConvertTo<T>() or GetValue<T>(string)) or indirectly (e.g. when deserializing a property within an attributed type).

Methods

GetConcreteType(IDictionary<string, Value>)

Type GetConcreteType(IDictionary<string, Value> map)

Returns the .NET type that a value should be deserialized as.

Parameter
Name Description
map IDictionarystringGoogle.Cloud.Firestore.V1.Value

The data associated with the value, as a map of string to Firestore Google.Cloud.Firestore.V1.Value objects. When this method is called during deserialization, the parameter value is not null and no values within the map are null.

Returns
Type Description
Type

The concrete type to be deserialized. Must not be null, and must be either T or some type assignable to it.