Class FieldBuilderExtensions
Provides useful extensions for manipulating field constructors via the FieldBuilder class.
Inherited Members
Namespace: TheXDS.MCART.Types.Extensions
Assembly: MCART.TypeFactory.dll
Syntax
public static class FieldBuilderExtensions
Methods
| Edit this page View SourceInitField(FieldBuilder, ILGenerator, object)
Initializes a field within the specified IL generator.
Declaration
public static void InitField(this FieldBuilder field, ILGenerator ilGen, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldBuilder | field | Field to initialize. |
| ILGenerator | ilGen | IL generator used to initialize the field. Usually it should be a class constructor. |
| object | value | Constant value with which the field should be initialized. |
InitField(FieldBuilder, ILGenerator, Type, params object[])
Initializes a field within the specified IL generator.
Declaration
public static void InitField(this FieldBuilder field, ILGenerator ilGen, Type instanceType, params object[] args)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldBuilder | field | Field to initialize. |
| ILGenerator | ilGen | IL generator used to initialize the field. Usually it should be a class constructor. |
| Type | instanceType | Type of object to instantiate. |
| object[] | args | Arguments to pass to the constructor of the specified type. |
Exceptions
| Type | Condition |
|---|---|
| InvalidTypeException | Thrown if the type is not instantiable. |
InitField<T>(FieldBuilder, ILGenerator)
Initializes a field within the specified IL generator.
Declaration
public static void InitField<T>(this FieldBuilder field, ILGenerator ilGen) where T : new()
Parameters
| Type | Name | Description |
|---|---|---|
| FieldBuilder | field | Field to initialize. |
| ILGenerator | ilGen | IL generator used to initialize the field. Usually it should be a class constructor. |
Type Parameters
| Name | Description |
|---|---|
| T | Type of value or object to instantiate. |