Class TryHandlerExtensions
- Namespace
- PatternKit.Common
- Assembly
- PatternKit.Core.dll
Extensions that add functional, chainable operations over compiled try-handlers.
public static class TryHandlerExtensions
- Inheritance
-
TryHandlerExtensions
- Inherited Members
Methods
FirstMatch<TIn, TOut>(TryHandler[], in TIn)
Returns the first successful result as an Option<T> for fluent chaining.
public static Option<TOut> FirstMatch<TIn, TOut>(this TryStrategy<TIn, TOut>.TryHandler[] handlers, in TIn input)
Parameters
handlersTryHandler[]The compiled handlers to evaluate.
inputTInThe input value.
Returns
Type Parameters
TInThe handler input type.
TOutThe handler output type.
Examples
var value = handlers.FirstMatch(in input).OrDefault();
TryGetResult<TIn, TOut>(TryHandler[], in TIn, out TOut?)
Attempts to obtain the first successful result from a compiled handler array.
public static bool TryGetResult<TIn, TOut>(this TryStrategy<TIn, TOut>.TryHandler[] handlers, in TIn input, out TOut? result)
Parameters
handlersTryHandler[]The compiled handlers to evaluate.
inputTInThe input value.
resultTOutThe first successful result, when found.
Returns
Type Parameters
TInThe handler input type.
TOutThe handler output type.