IntroduceParameterAndPull(string?, IType?, IExpression?)
Creates a pull strategy that introduces a new parameter in the child constructor and passes its value to the introduced parameter.
Declaration
public static IPullStrategy IntroduceParameterAndPull(string? name = null, IType? type = null, IExpression? defaultValue = null)Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name for the new parameter in the child constructor. If |
| IType | type | The type for the new parameter in the child constructor. If |
| IExpression | defaultValue | The default value for the new parameter in the child constructor. If |
Returns
| Type | Description |
|---|---|
| IPullStrategy | A pull strategy that introduces a new parameter in child constructors. |
Remarks
This strategy propagates the parameter requirement down the inheritance hierarchy. When a parameter is introduced in a base constructor using this strategy, each child constructor will also receive a new parameter (with the specified name, type, and default value), and that parameter's value will be passed to the base constructor.
This pull strategy operates across project boundaries. Changes are applied to all types derived from the modified type, even if those derived types are defined in different projects that reference the project containing the base type.
This is the most common pull strategy when you want derived classes to provide values for the introduced parameter, especially for dependency injection scenarios where dependencies should flow through the constructor hierarchy.
Example: If you introduce an ILogger parameter to a base class constructor with this strategy, all derived
class constructors will also get an ILogger parameter added, and they will pass it to the base constructor.