Class TypeFactory
Type factory. Allows defining and compiling new types at runtime.
Implements
Inherited Members
Namespace: TheXDS.MCART.Types
Assembly: MCART.TypeFactory.dll
Syntax
public class TypeFactory : IExposeAssembly
Constructors
| Edit this page View SourceTypeFactory()
Initializes a new instance of the TypeFactory class.
Declaration
[RequiresDynamicCode("The method makes calls to dynamic code, so it is not compatible with trimming.")]
public TypeFactory()
TypeFactory(bool)
Initializes a new instance of the TypeFactory class.
Declaration
[RequiresDynamicCode("The method makes calls to dynamic code, so it is not compatible with trimming.")]
public TypeFactory(bool useGuid)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | useGuid | True to append a GUID to generated type names. |
TypeFactory(string)
Initializes a new instance of the TypeFactory class.
Declaration
[RequiresDynamicCode("The method makes calls to dynamic code, so it is not compatible with trimming.")]
public TypeFactory(string @namespace)
Parameters
| Type | Name | Description |
|---|---|---|
| string | namespace | Namespace to use for the types to be built. |
TypeFactory(string, bool)
Initializes a new instance of the TypeFactory class.
Declaration
[RequiresDynamicCode("The method makes calls to dynamic code, so it is not compatible with trimming.")]
public TypeFactory(string @namespace, bool useGuid)
Parameters
| Type | Name | Description |
|---|---|---|
| string | namespace | Namespace to use for the types to be built. |
| bool | useGuid | True to append a GUID to generated type names. |
Properties
| Edit this page View SourceAssembly
Gets a reference to the dynamic assembly where types built by this TypeFactory are loaded.
Declaration
public Assembly Assembly { get; }
Property Value
| Type | Description |
|---|---|
| Assembly |
Methods
| Edit this page View SourceNewClass(string)
Creates a new public class.
Declaration
public TypeBuilder NewClass(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the new class. |
Returns
| Type | Description |
|---|---|
| TypeBuilder | A TypeBuilder that can be used to define members of the new class. |
NewClass(string, IEnumerable<Type>)
Creates a new public class.
Declaration
public TypeBuilder NewClass(string name, IEnumerable<Type> interfaces)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the new class. |
| IEnumerable<Type> | interfaces | Interfaces to implement. |
Returns
| Type | Description |
|---|---|
| TypeBuilder | A TypeBuilder that can be used to define members of the new class. |
NewClass<T>(string)
Creates a new public class, specifying the base type or single interface to implement.
Declaration
public ITypeBuilder<T> NewClass<T>(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the new class. |
Returns
| Type | Description |
|---|---|
| ITypeBuilder<T> | An ITypeBuilder<T> that can be used to define members of the new class. |
Type Parameters
| Name | Description |
|---|---|
| T | Base type or interface to implement. |
NewType(string, Type, IEnumerable<Type>)
Creates a new public class.
Declaration
public TypeBuilder NewType(string name, Type baseType, IEnumerable<Type> interfaces)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the new class. |
| Type | baseType | Base type of the new class. |
| IEnumerable<Type> | interfaces | Interfaces to implement by the new class. |
Returns
| Type | Description |
|---|---|
| TypeBuilder | A TypeBuilder that can be used to define members of the new class. |
NewType<T>(string)
Creates a new public class.
Declaration
public ITypeBuilder<T> NewType<T>(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the new class. |
Returns
| Type | Description |
|---|---|
| ITypeBuilder<T> | A TypeBuilder<T> that can be used to define members of the new class. |
Type Parameters
| Name | Description |
|---|---|
| T | Base type of the new class. |
NewType<T>(string, IEnumerable<Type>?)
Creates a new public class.
Declaration
public ITypeBuilder<T> NewType<T>(string name, IEnumerable<Type>? interfaces)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the new class. |
| IEnumerable<Type> | interfaces | Interfaces to implement by the new class. Can be set to null to implement no additional interface. |
Returns
| Type | Description |
|---|---|
| ITypeBuilder<T> | A TypeBuilder<T> that can be used to define members of the new class. |
Type Parameters
| Name | Description |
|---|---|
| T | Base type of the new class. |