Class ShieldResultExtensions
- Namespace
- Kevlar
- Assembly
- Kevlar.dll
Result-handling clauses for Shield<TResult> chains whose result is a reference
type. They are extension methods because only an extension method can constrain
TResult: a method declared on Shield<TResult> itself inherits whatever
the shield was built for, so a null clause written there would compile for int too.
public static class ShieldResultExtensions
- Inheritance
-
ShieldResultExtensions
- Inherited Members
Methods
OrResultIsNull<TResult>(ShieldBuilder<TResult>)
Returns a new builder that also handles null results.
public static ShieldBuilder<TResult> OrResultIsNull<TResult>(this ShieldBuilder<TResult> builder) where TResult : class?
Parameters
builderShieldBuilder<TResult>
Returns
- ShieldBuilder<TResult>
Type Parameters
TResult
Remarks
Prefer this to OrResultIsDefault() whenever the result is a reference type; see WhenResultIsNull<TResult>(Shield<TResult>).
WhenResultIsNull<TResult>(Shield<TResult>)
Starts a handling clause for null results. Use WithDefaultHandling() to return to default handling.
public static ShieldBuilder<TResult> WhenResultIsNull<TResult>(this Shield<TResult> shield) where TResult : class?
Parameters
shieldShield<TResult>
Returns
- ShieldBuilder<TResult>
Type Parameters
TResult
Remarks
Prefer this to WhenResultIsDefault() whenever the result is a
reference type: both match the same values, but this one cannot be written for a value type
whose default — 0, false — is usually a legitimate result
rather than a failure.