Open sandboxFocus

Class TypeFactory

Provides methods to obtain IType instances from reflection types, special types, or by constructing new types.

Inheritance
TypeFactory
Namespace: Metalama.Framework.Code
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public static class TypeFactory
Remarks

Use GetType(Type) or GetNamedType(Type) to convert a typeof expression to IType or INamedType. Use GetType(SpecialType) for efficient access to well-known types like string or int.

To create derived types from existing types, use methods on IType such as MakeArrayType(int), MakePointerType(), and ToNullable().

To create tuple types, use CreateTupleType(params IEnumerable<IType>) or its overloads.

Methods

Name Description
CreateTupleType(params IEnumerable<IParameter>)

Creates a tuple type with the specified parameters as elements.

CreateTupleType(params IEnumerable<IType>)

Creates a tuple type with the specified element types (given as IType) and default element names.

CreateTupleType(params IEnumerable<Type>)

Creates a tuple type with the specified element types (given as reflection Type's) and default element names.

CreateTupleType(params IEnumerable<(IType Type, string Name)>)

Creates a tuple type with the specified element types (given as IType's) and names.

CreateTupleType(params IEnumerable<(Type Type, string Name)>)

Creates a tuple type with the specified element types (given as reflection Type's) and names.

GetNamedType(Type)

Gets an INamedType given a reflection Type.

GetType(SpecialType)

Gets a INamedType representing a given SpecialType.

GetType(string)

Get type based on its full name, as used in reflection.

GetType(Type)

Gets an IType given a reflection Type.

ToNonNullableType(INamedType)
ToNonNullableType(IType)
ToNonNullableType(ITypeParameter)
ToNonNullableType(IArrayType)
ToNonNullableType(IDynamicType)
ToNullableType(INamedType)
ToNullableType(IType)
ToNullableType(IArrayType)
ToNullableType(IDynamicType)

See Also