CrystalJsonTypeDefinition

Namespace: SnowBank.Data.Json · class

Implements: IEquatable<CrystalJsonTypeDefinition>

Constructors

CrystalJsonTypeDefinition

CrystalJsonTypeDefinition(Type type, CrystalJsonTypeFlags flags, CrystalJsonTypeBinder customBinder, Func<object> generator, CrystalJsonMemberDefinition[] members, CrystalJsonTypeVisitor visitor, Type baseType, JsonEncodedPropertyName typeDiscriminatorProperty, JsonValue typeDiscriminatorValue, IReadOnlyDictionary<JsonValue, Type> derivedTypeMap)

Properties

BaseType

Type BaseType { get; set; }

ConstructorBinder

Func<JsonObject, ICrystalJsonTypeResolver, object> ConstructorBinder { get; set; }

Builds the instance from the document by calling a constructor with parameters, for a type that has no parameterless one (a positional record, a class whose constructors all take parameters)

Each parameter receives the value of the serialized member of the same name; those members are flagged and the member loop skips them. When set, is .

CustomBinder

CrystalJsonTypeBinder CustomBinder { get; set; }

Custom handler for deserializing JsonValue into instances of this type.

DefaultIsNull

bool DefaultIsNull { get; }

Types with a default value that is null

for Reference Types, or for .

DerivedTypeMap

FrozenDictionary<JsonValue, Type> DerivedTypeMap { get; set; }

Custom ClassId for this type

Flags

CrystalJsonTypeFlags Flags { get; set; }

Generator

Func<object> Generator { get; set; }

Factory method that can instantiate a new value of this type

HasSerializationCallbacks

bool HasSerializationCallbacks { get; }

Specifies if this type declares at least one serialization lifecycle callback

IsAnonymousType

bool IsAnonymousType { get; }

Specifies if this is an anonymous type that does not have a valid name

ex: CrystalJson.Serialize(new { "Hello": "World" })

IsNonConstructible

bool IsNonConstructible { get; }

Specifies if the type cannot be constructed directly (interface, abstract class, no public ctor, ...)

for interfaces or abstract types

IsOpaqueValueType

bool IsOpaqueValueType { get; }

Specifies that a JSON object is not a valid representation of this type, so the member binder must reject one

Classified once, when the contract is built. See .

IsPolymorphic

bool IsPolymorphic { get; }

IsSealed

bool IsSealed { get; }

Specifies if the type cannot possibly be derived (sealed class, or value type)

If , a type-check will have to be performed during serialization, which add some overhead

Members

CrystalJsonMemberDefinition[] Members { get; set; }

Definitions of the fields and properties of this type

NullableOfType

Type NullableOfType { get; set; }

Specifies if the type can have a value of null (ref types, or Nullable)

OnDeserialized

Action<object, JsonValue> OnDeserialized { get; set; }

[OnDeserializing] callback, invoked on a freshly constructed instance before its members are populated

The second argument is the document being bound, for callbacks declared as void M(JsonValue|JsonObject|JsonArray); a parameterless callback ignores it.

OnDeserializing

Action<object, JsonValue> OnDeserializing { get; set; }

[OnDeserializing] callback, invoked on a freshly constructed instance before its members are populated

The second argument is the document being bound, for callbacks declared as void M(JsonValue|JsonObject|JsonArray); a parameterless callback ignores it.

OnSerialized

Action<object> OnSerialized { get; set; }

[OnSerialized] callback, invoked after this type's members are written

OnSerializing

Action<object> OnSerializing { get; set; }

[OnSerializing] callback, invoked before this type's members are written

Type

Type Type { get; set; }

Type of the object

TypeDiscriminatorProperty

JsonEncodedPropertyName TypeDiscriminatorProperty { get; set; }

TypeDiscriminatorValue

JsonValue TypeDiscriminatorValue { get; set; }

Custom ClassId for this type

Visitor

CrystalJsonTypeVisitor Visitor { get; set; }

Custom visitor for serializing instances of this type

Methods

<Clone>$

CrystalJsonTypeDefinition <Clone>$()

Equals

bool Equals(object obj)

bool Equals(CrystalJsonTypeDefinition other)

GetHashCode

int GetHashCode()

ToString

string ToString()