RefParamExtensions Class
Provides the checks of a chain that starts with Param.CheckRef.
public static class RefParamExtensionsRemarks
A check throws an exception if the value of the parameter is not valid. Otherwise, it returns a RefParam<T>, so that another check can follow.
Every check takes an optional message for the exception it throws. The message is a composite format string, as the remarks of ParamExtensions describe it. The format item {0} is the name of the parameter. The value has no format item, because a ref struct cannot be converted to an object.
This type is not available in the netstandard and .NET Framework builds of Louis, because their BCL has no RuntimeFeature.ByRefLikeGenerics.
Methods
| Name | Description |
|---|---|
| RefParam<T>.Checked(Func<T, bool>, string?) | Throws an ArgumentException if the value of a parameter does not satisfy a condition. |
RefParam<T>.Checked(Func<T, bool>, string?)
Available in: net10.0net11.0(not available in the other target frameworks of the package)
Throws an ArgumentException if the value of a parameter does not satisfy a condition.
extension<T>(RefParam<T> @this) where T : allows ref struct
{
public RefParam<T> Checked(Func<T, bool> predicate, string? message = null)
}Type parameters
T- The type of the parameter.
Parameters
thisRefParam<T>- The
RefParam<T>that holds the value to check. predicateFunc<T, bool>- A function to test the value for a condition.
messagestring?- A composite format string for the message of the exception, or
nullto use the default message. The format item{0}is the name of the parameter.
Returns
RefParam<T> this, for the next check of the chain.
Exceptions
ArgumentNullExceptionpredicateisnull.ArgumentExceptionpredicatereturnsfalsefor the value ofthis.