Class SurrogateTypeDescriberBuilder
Builder for creating a SurrogateTypeDescriber.
Creates ITypeDescribers that inspects one type to determine who to (de)serialize 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
Namespace: Cesil
Assembly: Cesil.dll
Syntax
public sealed class SurrogateTypeDescriberBuilder : Object
Properties
FallbackBehavior
The configured behavior to use when a type has no registered surrogate.
Declaration
public SurrogateTypeDescriberFallbackBehavior FallbackBehavior { get; }
Property Value
Type | Description |
---|---|
SurrogateTypeDescriberFallbackBehavior |
FallbackTypeDescriber
ITypeDescriber that is used to discover providers or enumerate members if no registration exists and FallbackBehavior allows falling back.
Declaration
public ITypeDescriber FallbackTypeDescriber { get; }
Property Value
Type | Description |
---|---|
ITypeDescriber |
TypeDescriber
ITypeDescriber to use to discover providers and enumerate members on surrogate types.
Declaration
public ITypeDescriber TypeDescriber { get; }
Property Value
Type | Description |
---|---|
ITypeDescriber |
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 |
ToString()
Returns a representation of this SurrogateTypeDescriberBuilder object.
Only for debugging, this value is not guaranteed to be stable.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |
ToSurrogateTypeDescriber()
Create a SurrogateTypeDescriber with the options configured with this builder.
Declaration
public SurrogateTypeDescriber ToSurrogateTypeDescriber()
Returns
Type | Description |
---|---|
SurrogateTypeDescriber |
WithFallbackBehavior(SurrogateTypeDescriberFallbackBehavior)
Sets the behavior to fallback to when no surrogate type has been registered.
Declaration
public SurrogateTypeDescriberBuilder WithFallbackBehavior(SurrogateTypeDescriberFallbackBehavior fallbackBehavior)
Parameters
Type | Name | Description |
---|---|---|
SurrogateTypeDescriberFallbackBehavior | fallbackBehavior |
Returns
Type | Description |
---|---|
SurrogateTypeDescriberBuilder |
WithFallbackTypeDescriber(ITypeDescriber)
Sets the ITypeDescriber to use when no surrogate type has been registered, provided FallbackBehavior allows it.
Declaration
public SurrogateTypeDescriberBuilder WithFallbackTypeDescriber(ITypeDescriber fallbackTypeDescriber)
Parameters
Type | Name | Description |
---|---|---|
ITypeDescriber | fallbackTypeDescriber |
Returns
Type | Description |
---|---|
SurrogateTypeDescriberBuilder |
WithSurrogateType(TypeInfo, TypeInfo)
Registered a surrogate type for forType.
Whenever forType is passed to one of the EnumerateXXX methods, surrogateType will be used to discover members instead. The discovered members will then be mapped to forType, and returned.
Declaration
public SurrogateTypeDescriberBuilder WithSurrogateType(TypeInfo forType, TypeInfo surrogateType)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.TypeInfo | forType | |
System.Reflection.TypeInfo | surrogateType |
Returns
Type | Description |
---|---|
SurrogateTypeDescriberBuilder |
WithTypeDescriber(ITypeDescriber)
Sets the ITypeDescriber to use to discover providers and members on a surrogate type.
Declaration
public SurrogateTypeDescriberBuilder WithTypeDescriber(ITypeDescriber typeDescriber)
Parameters
Type | Name | Description |
---|---|---|
ITypeDescriber | typeDescriber |
Returns
Type | Description |
---|---|
SurrogateTypeDescriberBuilder |