CheckParameter Method
Definition
CheckParameter<T>(T, Action)
Provides a convenient way to verify a desired state from the provided validator while returning the specified argument unaltered.
public static T CheckParameter<T>(T argument, Action validator)
Parameters
argumentTThe value to be evaluated.
validatorActionThe delegate that must throw an Exception if the specified
argumentis not valid.
Returns
- T
The specified
argumentunaltered.
Type Parameters
TThe type of the object to evaluate.
Remarks
Typically used when nesting calls from a constructor perspective.
Exceptions
- ArgumentException
validatorcannot be null.
CheckParameter<TResult>(Func<TResult>)
Provides a convenient way to verify a desired state from the provided validator while returning a result that reflects this.
public static TResult CheckParameter<TResult>(Func<TResult> validator)
Parameters
validatorFunc<TResult>The function delegate that must throw an Exception if a desired state for
TResultcannot be achieved.
Returns
- TResult
The result of function delegate
validator.
Type Parameters
TResultThe type of the object to return.
Remarks
Typically used when nesting calls from a constructor perspective.
Exceptions
- ArgumentException
validatorcannot be null.