Metalama 1.0 / / Metalama Documentation / Aspect API Documentation / Metalama.​Framework.​Advising / IAdvice­Factory / Introduce­Field

Method IntroduceField

IntroduceField(INamedType, String, IntroductionScope, OverrideStrategy, Action<IFieldBuilder>, Object)

Introduces a field to the target type by specifying a template.

Declaration
IIntroductionAdviceResult<IField> IntroduceField(INamedType targetType, string template, IntroductionScope scope, OverrideStrategy whenExists, Action<IFieldBuilder> buildField = null, object tags = null)
Parameters
Type Name Description
INamedType targetType

The type into which the property must be introduced.

String template

Name of the introduced field.

IntroductionScope scope

Determines the scope (e.g. Instance or Static) of the introduced field. The default scope is Instance.

OverrideStrategy whenExists

Determines the implementation strategy when a property of the same name is already declared in the target type. The default strategy is to fail with a compile-time error.

Action<IFieldBuilder> buildField
Object tags
Returns
Type Description
IIntroductionAdviceResult<IField>

An IPropertyBuilder that allows to dynamically change the name or type of the introduced property.

See Also

IntroduceField(INamedType, String, IType, IntroductionScope, OverrideStrategy, Action<IFieldBuilder>, Object)

Introduces a field to the target type by specifying a field name and IType.

Declaration
IIntroductionAdviceResult<IField> IntroduceField(INamedType targetType, string fieldName, IType fieldType, IntroductionScope scope, OverrideStrategy whenExists, Action<IFieldBuilder> buildField = null, object tags = null)
Parameters
Type Name Description
INamedType targetType

The type into which the property must be introduced.

String fieldName

Name of the introduced field.

IType fieldType

Type of the introduced field.

IntroductionScope scope

Determines the scope (e.g. Instance or Static) of the introduced field. The default scope is Instance.

OverrideStrategy whenExists

Determines the implementation strategy when a property of the same name is already declared in the target type. The default strategy is to fail with a compile-time error.

Action<IFieldBuilder> buildField
Object tags
Returns
Type Description
IIntroductionAdviceResult<IField>

An IPropertyBuilder that allows to dynamically change the name or type of the introduced property.

See Also

IntroduceField(INamedType, String, Type, IntroductionScope, OverrideStrategy, Action<IFieldBuilder>, Object)

Introduces a field to the target type by specifying a field name and Type.

Declaration
IIntroductionAdviceResult<IField> IntroduceField(INamedType targetType, string fieldName, Type fieldType, IntroductionScope scope, OverrideStrategy whenExists, Action<IFieldBuilder> buildField = null, object tags = null)
Parameters
Type Name Description
INamedType targetType

The type into which the property must be introduced.

String fieldName

Name of the introduced field.

Type fieldType

Type of the introduced field.

IntroductionScope scope

Determines the scope (e.g. Instance or Static) of the introduced field. The default scope is Instance.

OverrideStrategy whenExists

Determines the implementation strategy when a property of the same name is already declared in the target type. The default strategy is to fail with a compile-time error.

Action<IFieldBuilder> buildField
Object tags
Returns
Type Description
IIntroductionAdviceResult<IField>

An IPropertyBuilder that allows to dynamically change the name or type of the introduced property.

See Also