Class TypeSchema
The schema definition used when serializing and deserializing a type.
Inherited Members
Namespace: Microsoft.Psi.Serialization
Assembly: Microsoft.Psi.dll
Syntax
public sealed class TypeSchema : Metadata
Constructors
View SourceTypeSchema(String, TypeFlags, IEnumerable<TypeMemberSchema>, String, Int32, Int32, String, Int32)
Initializes a new instance of the TypeSchema class.
Declaration
public TypeSchema(string typeName, TypeFlags flags, IEnumerable<TypeMemberSchema> members, string name, int id, int version, string serializerTypeName, int serializationSystemVersion)
Parameters
Type | Name | Description |
---|---|---|
String | typeName | The assembly-qualified name for the data type represented by the schema. |
TypeFlags | flags | The type flags. |
IEnumerable<TypeMemberSchema> | members | The serializable members of the type, in the correct order. |
String | name | The contract name. |
System.Int32 | id | The id, as generated by GetId(String). |
System.Int32 | version | The schema version. |
String | serializerTypeName | The assembly qualified name of the serializer type. |
System.Int32 | serializationSystemVersion | The version of the serialization system. |
Properties
View SourceFlags
Gets the type flags.
Declaration
public TypeFlags Flags { get; }
Property Value
Type | Description |
---|---|
TypeFlags |
IsPartial
Gets a value indicating whether type is partial.
Declaration
public bool IsPartial { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Members
Gets the serializable members of the type.
Declaration
public TypeMemberSchema[] Members { get; }
Property Value
Type | Description |
---|---|
TypeMemberSchema[] |
SerializerTypeName
Gets the assembly qualified name of the serializer type.
Declaration
public string SerializerTypeName { get; }
Property Value
Type | Description |
---|---|
String |
TypeName
Gets the name of the type of data described by the schema.
Declaration
public string TypeName { get; }
Property Value
Type | Description |
---|---|
String |
Methods
View SourceFromType(Type, String, Int32)
Generates a schema for the specified type.
Declaration
public static TypeSchema FromType(Type type, string serializerTypeAssemblyQualifiedName, int serializationSystemVersion)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type to generate the schema for. |
String | serializerTypeAssemblyQualifiedName | The assembly qualified name of the type of the serializer generating the schema. |
System.Int32 | serializationSystemVersion | The version of the serialization system used. |
Returns
Type | Description |
---|---|
TypeSchema | A schema describing the serialization information for the specified type. |
Remarks
The schema version is assigned in this case to the serializationSystemVersion
.
If you would like to generate a schema with a specific version, use the FromType(Type, String, Int32, Int32) overload.
If the type is DataContract-compatible (and serializationSystemVersion
> 0), the schema is based on DataContract rules
(see https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/serializable-types?view=netframework-4.7)
If not, the schema is based on binary serialization rules (see https://docs.microsoft.com/en-us/dotnet/api/system.serializableattribute?view=netframework-4.7).
FromType(Type, String, Int32, Int32)
Generates a schema with a specified version for the specified type.
Declaration
public static TypeSchema FromType(Type type, string serializerTypeName, int version, int serializationSystemVersion)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type to generate the schema for. |
String | serializerTypeName | The assembly qualified name of the type of the serializer generating the schema. |
System.Int32 | version | The version for the generated schema. |
System.Int32 | serializationSystemVersion | The version of the serialization system used. |
Returns
Type | Description |
---|---|
TypeSchema | A schema describing the serialization information for the specified type. |
Remarks
If the type is DataContract-compatible (and serializationSystemVersion
> 0), the schema is based on DataContract rules
(see https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/serializable-types?view=netframework-4.7)
If not, the schema is based on binary serialization rules (see https://docs.microsoft.com/en-us/dotnet/api/system.serializableattribute?view=netframework-4.7).
GetCompatibleMemberSet(TypeSchema)
Retrieves the
Declaration
public IEnumerable<MemberInfo> GetCompatibleMemberSet(TypeSchema targetSchema = null)
Parameters
Type | Name | Description |
---|---|---|
TypeSchema | targetSchema | The schema specification describing which members and in which order to enumerate. If null, all members are returned in their original order. |
Returns
Type | Description |
---|---|
IEnumerable<MemberInfo> | A collection of |
GetContractName(Type, Int32)
Returns the contract name for a given type, which is either the DataContract name, if available, or the assembly-qualified type name.
Declaration
public static string GetContractName(Type type, int serializationSystemVersion)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type to generate the name for. |
System.Int32 | serializationSystemVersion | The version of the serialization system. |
Returns
Type | Description |
---|---|
String | The DataContract name, if available, or the assembly-qualified type name. |
GetId(String)
Returns a unique ID for the given contract name.
Declaration
public static int GetId(string contractName)
Parameters
Type | Name | Description |
---|---|---|
String | contractName | The contract name. |
Returns
Type | Description |
---|---|
System.Int32 | A hash of the contract name. |
ValidateCompatibleWith(TypeSchema)
Validate whether two schemas are compatible.
Declaration
public void ValidateCompatibleWith(TypeSchema other)
Parameters
Type | Name | Description |
---|---|---|
TypeSchema | other | Other type schema. |
Remarks
Schemas are compatible if all required fields are present in both (regardless of type).