Class SurrogateTypeDescriber

A ITypeDesciber that enumerates members on a surrogate type and maps them to another type.

Used when you don't control the type you need to (de)serialize - you markup the surrogate type and then the uncontrolled type is (de)serialized as if it were the surrogate type.

Inheritance
System.Object
SurrogateTypeDescriber
Implements
ITypeDescriber
System.IEquatable<SurrogateTypeDescriber>
Namespace: Cesil
Assembly: Cesil.dll
Syntax
public sealed class SurrogateTypeDescriber : Object, ITypeDescriber, IEquatable<SurrogateTypeDescriber>

Methods

CreateBuilder()

Creates a SurrogateTypeDescriberBuilder which using TypeDescriber.Default to describes surrogates, and falls back to TypeDescriber.Default if no surrogate is registered.

Declaration
public static SurrogateTypeDescriberBuilder CreateBuilder()
Returns
Type Description
SurrogateTypeDescriberBuilder

CreateBuilder(SurrogateTypeDescriber)

Creates a SurrogateTypeDescriberBuilder which copies it's fallback behavior, type describer, fallback type describer, and surrogate types from the given SurrogateTypeDescriber.

Declaration
public static SurrogateTypeDescriberBuilder CreateBuilder(SurrogateTypeDescriber typeDescriber)
Parameters
Type Name Description
SurrogateTypeDescriber typeDescriber
Returns
Type Description
SurrogateTypeDescriberBuilder

CreateBuilder(SurrogateTypeDescriberFallbackBehavior)

Creates a SurrogateTypeDescriberBuilder with the given fallback behavior.

Uses TypeDescriber.Default to describes surrogates, and falls back to TypeDescriber.Default if no surrogate is registered and the provided SurrogateTypeDescriberFallbackBehavior allows it.

Declaration
public static SurrogateTypeDescriberBuilder CreateBuilder(SurrogateTypeDescriberFallbackBehavior fallbackBehavior)
Parameters
Type Name Description
SurrogateTypeDescriberFallbackBehavior fallbackBehavior
Returns
Type Description
SurrogateTypeDescriberBuilder

CreateBuilder(SurrogateTypeDescriberFallbackBehavior, ITypeDescriber)

Creates a SurrogateTypeDescriberBuilder with the given fallback behavior and type describer.

Uses the given ITypeDescriber to describes surrogates, and falls back to TypeDescriber.Default if no surrogate is registered if the provided SurrogateTypeDescriberFallbackBehavior allows it.

Declaration
public static SurrogateTypeDescriberBuilder CreateBuilder(SurrogateTypeDescriberFallbackBehavior fallbackBehavior, ITypeDescriber typeDescriber)
Parameters
Type Name Description
SurrogateTypeDescriberFallbackBehavior fallbackBehavior
ITypeDescriber typeDescriber
Returns
Type Description
SurrogateTypeDescriberBuilder

CreateBuilder(SurrogateTypeDescriberFallbackBehavior, ITypeDescriber, ITypeDescriber)

Creates a SurrogateTypeDescriberBuilder with the given fallback behavior, type describer, and fallback type describer.

Uses the given ITypeDescriber to describes surrogates, and falls back to provided fallback if no surrogate is registered and the provided SurrogateTypeDescriberFallbackBehavior allows it.

Declaration
public static SurrogateTypeDescriberBuilder CreateBuilder(SurrogateTypeDescriberFallbackBehavior fallbackBehavior, ITypeDescriber typeDescriber, ITypeDescriber fallbackTypeDescriber)
Parameters
Type Name Description
SurrogateTypeDescriberFallbackBehavior fallbackBehavior
ITypeDescriber typeDescriber
ITypeDescriber fallbackTypeDescriber
Returns
Type Description
SurrogateTypeDescriberBuilder

EnumerateMembersToDeserialize(TypeInfo)

Enumerate all the members on forType to deserialize.

If a surrogate is registered, the surrogate will be used for discovery - the returned members will be mapped from the surrogate to forType.

If a surrogate is not registered, either an exception will be thrown or forType will be passed to TypeDescriber.EnumerateMembersToDeserialize depending on the value of ThrowOnNoRegisteredSurrogate.

Declaration
public IEnumerable<DeserializableMember> EnumerateMembersToDeserialize(TypeInfo forType)
Parameters
Type Name Description
System.Reflection.TypeInfo forType
Returns
Type Description
System.Collections.Generic.IEnumerable<DeserializableMember>

EnumerateMembersToSerialize(TypeInfo)

Enumerate all the members on forType to serialize.

If a surrogate is registered, the surrogate will be used for discovery - the returned members will be mapped from the surrogate to forType.

If a surrogate is not registered, either an exception will be thrown or forType will be passed to TypeDescriber.EnumerateMembersToSerialize depending on the value of ThrowOnNoRegisteredSurrogate.

Declaration
public IEnumerable<SerializableMember> EnumerateMembersToSerialize(TypeInfo forType)
Parameters
Type Name Description
System.Reflection.TypeInfo forType
Returns
Type Description
System.Collections.Generic.IEnumerable<SerializableMember>

Equals(SurrogateTypeDescriber)

Returns true if this SurrogateTypeDescriber equals the given SurrogateTypeDescriber.

Declaration
public bool Equals(SurrogateTypeDescriber typeDescriber)
Parameters
Type Name Description
SurrogateTypeDescriber typeDescriber
Returns
Type Description
System.Boolean

Equals(Object)

Returns true if this SurrogateTypeDescriber equals the given object

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj
Returns
Type Description
System.Boolean

GetCellsForDynamicRow(WriteContext, Object, Span<DynamicCellValue>)

Delegates to TypeDescriber.

Declaration
public int GetCellsForDynamicRow(in WriteContext context, object row, Span<DynamicCellValue> cells)
Parameters
Type Name Description
WriteContext context
System.Object row
System.Span<DynamicCellValue> cells
Returns
Type Description
System.Int32

GetDynamicCellParserFor(ReadContext, TypeInfo)

Delegates to TypeDescriber.

Declaration
public Parser GetDynamicCellParserFor(in ReadContext context, TypeInfo targetType)
Parameters
Type Name Description
ReadContext context
System.Reflection.TypeInfo targetType
Returns
Type Description
Parser

GetDynamicRowConverter(ReadContext, IEnumerable<ColumnIdentifier>, TypeInfo)

Delegates to TypeDescriber.

Declaration
public DynamicRowConverter GetDynamicRowConverter(in ReadContext context, IEnumerable<ColumnIdentifier> columns, TypeInfo targetType)
Parameters
Type Name Description
ReadContext context
System.Collections.Generic.IEnumerable<ColumnIdentifier> columns
System.Reflection.TypeInfo targetType
Returns
Type Description
DynamicRowConverter

GetHashCode()

Returns a stable hash for this SurrogateTypeDescriber.

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32

GetInstanceProvider(TypeInfo)

Gets an instance builder usable to construct the given type.

If a surrogate is registered, the surrogate will be used for discovery - the returned constructor will be mapped from the surrogate to forType.

If a surrogate is not registered, either an exception will be thrown or forType will be passed to TypeDescriber.GetInstanceProvider depending on the value of ThrowOnNoRegisteredSurrogate.

Declaration
public InstanceProvider GetInstanceProvider(TypeInfo forType)
Parameters
Type Name Description
System.Reflection.TypeInfo forType
Returns
Type Description
InstanceProvider

ToString()

Returns a representation of this SurrogateTypeDescriber object.

Only for debugging, this value is not guaranteed to be stable.

Declaration
public override string ToString()
Returns
Type Description
System.String

Operators

Equality(SurrogateTypeDescriber, SurrogateTypeDescriber)

Compare two SurrogateTypeDescribers for equality

Declaration
public static bool operator ==(SurrogateTypeDescriber a, SurrogateTypeDescriber b)
Parameters
Type Name Description
SurrogateTypeDescriber a
SurrogateTypeDescriber b
Returns
Type Description
System.Boolean

Inequality(SurrogateTypeDescriber, SurrogateTypeDescriber)

Compare two SurrogateTypeDescribers for inequality

Declaration
public static bool operator !=(SurrogateTypeDescriber a, SurrogateTypeDescriber b)
Parameters
Type Name Description
SurrogateTypeDescriber a
SurrogateTypeDescriber b
Returns
Type Description
System.Boolean

Explicit Interface Implementations

ITypeDescriber.GetCellsForDynamicRow(WriteContext, Object, Span<DynamicCellValue>)

Declaration
int ITypeDescriber.GetCellsForDynamicRow(in WriteContext context, object row, Span<DynamicCellValue> cells)
Parameters
Type Name Description
WriteContext context
System.Object row
System.Span<DynamicCellValue> cells
Returns
Type Description
System.Int32

ITypeDescriber.GetDynamicCellParserFor(ReadContext, TypeInfo)

Declaration
Parser ITypeDescriber.GetDynamicCellParserFor(in ReadContext context, TypeInfo targetType)
Parameters
Type Name Description
ReadContext context
System.Reflection.TypeInfo targetType
Returns
Type Description
Parser

ITypeDescriber.GetDynamicRowConverter(ReadContext, IEnumerable<ColumnIdentifier>, TypeInfo)

Declaration
DynamicRowConverter ITypeDescriber.GetDynamicRowConverter(in ReadContext context, IEnumerable<ColumnIdentifier> columns, TypeInfo targetType)
Parameters
Type Name Description
ReadContext context
System.Collections.Generic.IEnumerable<ColumnIdentifier> columns
System.Reflection.TypeInfo targetType
Returns
Type Description
DynamicRowConverter

Implements

ITypeDescriber
System.IEquatable<>
In This Article
Back to top Generated by DocFX