AddInitializer(INamedType, string, InitializerKind, object?, object?, IEnumerable<IField>?)
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, IEnumerable<IField>? slotFields = 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. |
| IEnumerable<IField> | slotFields | An optional collection of IField references to |
Returns
| Type | Description |
|---|---|
| IAddInitializerAdviceResult |
AddInitializer(INamedType, string, InitializerKind, InitializerPosition, object?, object?, IEnumerable<IField>?)
Adds a type or instance initializer by using a template, specifying whether the initializer should run before or after the call to the base initializer.
Declaration
IAddInitializerAdviceResult AddInitializer(INamedType targetType, string template, InitializerKind kind, InitializerPosition position, object? tags = null, object? args = null, IEnumerable<IField>? slotFields = 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. Must be AfterObjectInitializer or AfterLastInstanceConstructor. |
| InitializerPosition | position | Position of the initializer relative to the call to the base initializer ( |
| 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. |
| IEnumerable<IField> | slotFields | An optional collection of IField references to |
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 |