Class Generator<TInterface, TDescendant>
Base of typed generators.
Inheritance
Namespace: Solti.Utils.Proxy.Internals
Assembly: Solti.Utils.Proxy.dll
Syntax
public abstract class Generator<TInterface, TDescendant> : Object where TDescendant : Generator<TInterface, TDescendant>, new()
Type Parameters
Name | Description |
---|---|
TInterface | |
TDescendant |
Remarks
Generators should not be instantiated. To access the created System.Type use the GetGeneratedType() or GetGeneratedTypeAsync(CancellationToken) method.
Constructors
Generator()
Declaration
protected Generator()
Properties
Instance
The singleton generator instance.
Declaration
public static Generator Instance { get; }
Property Value
Type | Description |
---|---|
Generator |
Methods
Activate(ITuple)
Creates an instance of the generated type.
Declaration
public static TInterface Activate(ITuple tuple)
Parameters
Type | Name | Description |
---|---|---|
System.Runtime.CompilerServices.ITuple | tuple | A System.Tuple containing the constructor parameters or null if you want to invoke the parameterless constructor. |
Returns
Type | Description |
---|---|
TInterface | The just activated instance. |
ActivateAsync(ITuple, CancellationToken)
Creates an instance of the generated type.
Declaration
public static Task<TInterface> ActivateAsync(ITuple tuple, CancellationToken cancellation = null)
Parameters
Type | Name | Description |
---|---|---|
System.Runtime.CompilerServices.ITuple | tuple | A System.Tuple containing the constructor parameters or null if you want to invoke the parameterless constructor. |
System.Threading.CancellationToken | cancellation | Token to cancel the operation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TInterface> | The just activated instance. |
GetConcreteGenerator()
Gets the concrete generator.
Declaration
protected abstract Generator GetConcreteGenerator()
Returns
Type | Description |
---|---|
Generator |
GetGeneratedType()
Gets the generated System.Type.
Declaration
public static Type GetGeneratedType()
Returns
Type | Description |
---|---|
System.Type |
Remarks
The returned System.Type is generated only once.
GetGeneratedTypeAsync(CancellationToken)
Gets the generated System.Type asynchronously .
Declaration
public static Task<Type> GetGeneratedTypeAsync(CancellationToken cancellation = null)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellation |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Type> |
Remarks
The returned System.Type is generated only once.