Show / Hide Table of Contents

Class DataType

Abstract base class for data types that conform to the data model.

Inheritance
System.Object
DataType
ArrayDataType
ExpressionDataType
FunctionDataType
OpenGenericParameterDataType
PrimitiveDataType
QuotationDataType
StructuralDataType
Namespace: Nuqleon.DataModel.TypeSystem
Assembly: Nuqleon.DataModel.CompilerServices.dll
Syntax
public abstract class DataType : Object

Constructors

DataType(Type)

Creates a new data type of the specified kind.

Declaration
protected DataType(Type type)
Parameters
Type Name Description
System.Type type

Underlying CLR type.

Properties

Kind

Gets the kind of the data type.

Declaration
public abstract DataTypeKinds Kind { get; }
Property Value
Type Description
DataTypeKinds

UnderlyingType

Gets the underlying CLR type.

Declaration
public Type UnderlyingType { get; }
Property Value
Type Description
System.Type

Methods

Check(Type)

Checks whether the specified CLR type can be converted to a valid data model type. No recursive type definitions are allowed. Violations against the data model type system are reported as an exception.

Declaration
public static void Check(Type type)
Parameters
Type Name Description
System.Type type

CLR type to check.

Exceptions
Type Condition
System.AggregateException

Aggregate exception with DataTypeException inner exception objects to describe violations against the data model type system.

Check(Type, Boolean)

Checks whether the specified CLR type can be converted to a valid data model type. Support for recursive type definitions can be enabled. Violations against the data model type system are reported as an exception.

Declaration
public static void Check(Type type, bool allowCycles)
Parameters
Type Name Description
System.Type type

CLR type to check.

System.Boolean allowCycles

Indicates whether cycles in type definitions are allowed. This is a specialized use case and should be considered carefully, because not all tools can deal with cycles.

Exceptions
Type Condition
System.AggregateException

Aggregate exception with DataTypeException inner exception objects to describe violations against the data model type system.

CheckType(Object)

Checks whether the specified object is assignable to the data type.

Declaration
protected void CheckType(object value)
Parameters
Type Name Description
System.Object value

Object to check for assignment compatibility.

CreateInstance(Object[])

Creates a new instance of the data type, using the specified construction arguments.

Declaration
public abstract object CreateInstance(params object[] arguments)
Parameters
Type Name Description
System.Object[] arguments

Arguments used for construction of the data type instance.

Returns
Type Description
System.Object

New instance of the data type.

FromType(Type)

Converts a CLR type to a data model type. No recursive type definitions are allowed.

Declaration
public static DataType FromType(Type type)
Parameters
Type Name Description
System.Type type

CLR type to convert.

Returns
Type Description
DataType

Data model type isomorphic to the given CLR type.

FromType(Type, Boolean)

Converts a CLR type to a data model type. Support for recursive type definitions can be enabled.

Declaration
public static DataType FromType(Type type, bool allowCycles)
Parameters
Type Name Description
System.Type type

CLR type to convert.

System.Boolean allowCycles

Indicates whether cycles in type definitions are allowed. This is a specialized use case and should be considered carefully, because not all tools can deal with cycles.

Returns
Type Description
DataType

Data model type isomorphic to the given CLR type.

IsEntityEnumDataType(Type)

Checks whether the specified CLR type represents a user-defined entity enumeration data type. This method doesn't perform extensive checking of required invariants. Use FromType or Check to ensure the type is a valid entity type.

Declaration
public static bool IsEntityEnumDataType(Type type)
Parameters
Type Name Description
System.Type type

CLR type to check.

Returns
Type Description
System.Boolean

true if the given CLR type represents a user-defined entity enumeration data type; otherwise, false.

IsStructuralEntityDataType(Type)

Checks whether the specified CLR type represents a user-defined structural entity data type. This method doesn't perform extensive checking of required invariants. Use FromType or Check to ensure the type is a valid entity type.

Declaration
public static bool IsStructuralEntityDataType(Type type)
Parameters
Type Name Description
System.Type type

CLR type to check.

Returns
Type Description
System.Boolean

true if the given CLR type represents a user-defined structural entity data type; otherwise, false.

Reduce()

Reduces the data type to a simpler data type representation.

Declaration
public virtual DataType Reduce()
Returns
Type Description
DataType

Simpler data type representation, if available. Otherwise, the current object is returned.

ToString()

Returns a friendly string representation of the type.

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

Friendly string representation of the type.

TryCheck(Type, Boolean, out ReadOnlyCollection<DataTypeError>)

Checks whether the specified CLR type can be converted to a valid data model type. Support for recursive type definitions can be enabled. Violations against the data model type system are reported through the output parameter.

Declaration
public static bool TryCheck(Type type, bool allowCycles, out ReadOnlyCollection<DataTypeError> errors)
Parameters
Type Name Description
System.Type type

CLR type to check.

System.Boolean allowCycles

Indicates whether cycles in type definitions are allowed. This is a specialized use case and should be considered carefully, because not all tools can deal with cycles.

System.Collections.ObjectModel.ReadOnlyCollection<DataTypeError> errors

Violations against the data model type system.

Returns
Type Description
System.Boolean

true if the given CLR type passes data model type checking; otherwise, false.

TryCheck(Type, out ReadOnlyCollection<DataTypeError>)

Checks whether the specified CLR type can be converted to a valid data model type. No recursive type definitions are allowed. Violations against the data model type system are reported through the output parameter.

Declaration
public static bool TryCheck(Type type, out ReadOnlyCollection<DataTypeError> errors)
Parameters
Type Name Description
System.Type type

CLR type to check.

System.Collections.ObjectModel.ReadOnlyCollection<DataTypeError> errors

Violations against the data model type system.

Returns
Type Description
System.Boolean

true if the given CLR type passes data model type checking; otherwise, false.

TryCheckType(Object)

Tries to check whether the specified object is assignable to the data type.

Declaration
protected bool TryCheckType(object value)
Parameters
Type Name Description
System.Object value

Object to check for assignment compatibility.

Returns
Type Description
System.Boolean

true if the object can be assigned to the data type; otherwise, false.

TryFromType(Type, out DataType)

Tries to convert a CLR type to a data model type. No recursive type definitions are allowed.

Declaration
public static bool TryFromType(Type type, out DataType result)
Parameters
Type Name Description
System.Type type

CLR type to convert.

DataType result

Data model type isomorphic to the given CLR type.

Returns
Type Description
System.Boolean

true if the conversion succeeded; otherwise, false.

TryFromType(Type, Boolean, out DataType)

Tries to convert a CLR type to a data model type. Support for recursive type definitions can be enabled.

Declaration
public static bool TryFromType(Type type, bool allowCycles, out DataType result)
Parameters
Type Name Description
System.Type type

CLR type to convert.

System.Boolean allowCycles

Indicates whether cycles in type definitions are allowed. This is a specialized use case and should be considered carefully, because not all tools can deal with cycles.

DataType result

Data model type isomorphic to the given CLR type.

Returns
Type Description
System.Boolean

true if the conversion succeeded; otherwise, false.

In This Article
Back to top Generated by DocFX