Open sandboxFocus

Method IntroduceParameter

IntroduceParameter(IAdviser<IConstructor>, string, IType, TypedConstant, Func<IParameter, IConstructor, PullAction>?, ImmutableArray<AttributeConstruction>)

Appends a parameter to a constructor by specifying its name and IType. Use the With<TNewDeclaration>(TNewDeclaration) method to apply the advice to another declaration than the current one.

Declaration
public static IIntroductionAdviceResult<IParameter> IntroduceParameter(this IAdviser<IConstructor> adviser, string parameterName, IType parameterType, TypedConstant defaultValue, Func<IParameter, IConstructor, PullAction>? pullAction = null, ImmutableArray<AttributeConstruction> attributes = default)
Parameters
Type Name Description
IAdviser<IConstructor> adviser

An adviser for a constructor.

string parameterName

The name of the parameter.

IType parameterType

The type of the parameter.

TypedConstant defaultValue

The default value of the parameter (required). It must be type-compatible with parameterType. To specify default as the default value, use Default(IType).

Func<IParameter, IConstructor, PullAction> pullAction

An optional delegate that returns a PullAction specifying how to pull the new parameter from other child constructors. A null value is equivalent to None, i.e. defaultValue of the parameter will be used.

ImmutableArray<AttributeConstruction> attributes
Returns
Type Description
IIntroductionAdviceResult<IParameter>

IntroduceParameter(IAdviser<IConstructor>, string, Type, TypedConstant, Func<IParameter, IConstructor, PullAction>?, ImmutableArray<AttributeConstruction>)

Appends a parameter to a constructor by specifying its name and Type. Use the With<TNewDeclaration>(TNewDeclaration) method to apply the advice to another declaration than the current one.

Declaration
public static IIntroductionAdviceResult<IParameter> IntroduceParameter(this IAdviser<IConstructor> adviser, string parameterName, Type parameterType, TypedConstant defaultValue, Func<IParameter, IConstructor, PullAction>? pullAction = null, ImmutableArray<AttributeConstruction> attributes = default)
Parameters
Type Name Description
IAdviser<IConstructor> adviser

An adviser for a constructor.

string parameterName

The name of the parameter.

Type parameterType

The type of the parameter.

TypedConstant defaultValue

The default value of the parameter (required). It must be type-compatible with parameterType. To specify default as the default value, use Default(IType).

Func<IParameter, IConstructor, PullAction> pullAction

An optional delegate that returns a PullAction specifying how to pull the new parameter from other child constructors. A null value is equivalent to None, i.e. defaultValue of the parameter will be used.

ImmutableArray<AttributeConstruction> attributes
Returns
Type Description
IIntroductionAdviceResult<IParameter>