IAdviceFactory.AddInitializer Method
AddInitializer(INamedType, string, InitializerKind, object?, object?)
Adds a type or instance initializer by using a template.
Declaration
IAddInitializerAdviceResult AddInitializer(INamedType targetType, string template, InitializerKind kind, object? tags = null, object? args = null)
Parameters
Type | Name | Description |
---|---|---|
INamedType | targetType | The type into which the initializer should be added. |
string | template | The name of the template. This method must have no run-time parameter, be of |
InitializerKind | kind | The type of initializer to add. |
object | tags | An optional opaque object of anonymous type passed to templates and exposed under the Tags property of the meta API. |
object | args | An object (typically of anonymous type) whose properties map to parameters or type parameters of the template. |
Returns
Type | Description |
---|---|
IAddInitializerAdviceResult |
AddInitializer(INamedType, IStatement, InitializerKind)
Adds a type or instance initializer by specifying an IStatement.
Declaration
IAddInitializerAdviceResult AddInitializer(INamedType targetType, IStatement statement, InitializerKind kind)
Parameters
Type | Name | Description |
---|---|---|
INamedType | targetType | The type into which the initializer should be added. |
IStatement | statement | The statement to be inserted at the top of constructors. |
InitializerKind | kind | The type of initializer to add. |
Returns
Type | Description |
---|---|
IAddInitializerAdviceResult |
AddInitializer(IConstructor, string, object?, object?)
Adds an initializer to a specific constructor by using a template.
Declaration
IAddInitializerAdviceResult AddInitializer(IConstructor targetConstructor, string template, object? tags = null, object? args = null)
Parameters
Type | Name | Description |
---|---|---|
IConstructor | targetConstructor | The constructor into which the initializer should be added. |
string | template | The name of the template. This method must have no run-time parameter, be of |
object | tags | An optional opaque object of anonymous type passed to templates and exposed under the Tags property of the meta API. |
object | args | An object (typically of anonymous type) whose properties map to parameters or type parameters of the template. |
Returns
Type | Description |
---|---|
IAddInitializerAdviceResult |
AddInitializer(IConstructor, IStatement)
Adds an initializer to a specific constructor by specifying an IStatement.
Declaration
IAddInitializerAdviceResult AddInitializer(IConstructor targetConstructor, IStatement statement)
Parameters
Type | Name | Description |
---|---|---|
IConstructor | targetConstructor | The constructor into which the initializer should be added. |
IStatement | statement | The statement to be inserted at the top of the constructor. |
Returns
Type | Description |
---|---|
IAddInitializerAdviceResult |