MetalamaAPI documentationAspect APIMetalama.​Framework.​AdvisingIAdvice­FactoryAdd­Initializer
Open sandboxFocus

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.

System.String template

The name of the template. This method must have no run-time parameter, be of void return type, and be annotated with the TemplateAttribute custom attribute.

InitializerKind kind

The type of initializer to add.

System.Object tags

An optional opaque object of anonymous type passed to templates and exposed under the Tags property of the meta API.

System.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.

System.String template

The name of the template. This method must have no run-time parameter, be of void return type, and be annotated with the TemplateAttribute custom attribute.

System.Object tags

An optional opaque object of anonymous type passed to templates and exposed under the Tags property of the meta API.

System.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