If<T>(IEligibilityBuilder<T>, Predicate<T>)
Returns an IEligibilityBuilder that conditionally applies rules based on a predicate. Rules added to the returned builder are only evaluated if the condition is satisfied.
Declaration
public static IEligibilityBuilder<T> If<T>(this IEligibilityBuilder<T> eligibilityBuilder, Predicate<T> condition) where T : classParameters
| Type | Name | Description |
|---|---|---|
| IEligibilityBuilder<T> | eligibilityBuilder | The parent eligibility builder. |
| Predicate<T> | condition | A predicate that determines whether the following rules should be evaluated.
If this returns |
Returns
| Type | Description |
|---|---|
| IEligibilityBuilder<T> | An eligibility builder where rules are only evaluated when the condition is true. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of declaration being validated. |
Remarks
Use this method when eligibility depends on a condition. For example, you might require static methods to have
no parameters, but allow instance methods to have parameters. The rules added after If only apply
when the condition is met.
This is conceptually similar to: "If the declaration is X, then it must also satisfy Y." If the declaration is not X, the Y requirement is ignored.