Class OneOfResultIntegrationExtensions
- Namespace
- REslava.Result.AdvancedPatterns
- Assembly
- REslava.Result.dll
Pipeline integration extensions for seamless OneOf and Result interoperability. Enables mixed workflows where both patterns can work together naturally.
public static class OneOfResultIntegrationExtensions
- Inheritance
-
OneOfResultIntegrationExtensions
- Inherited Members
Methods
BindToResult<T1, T2, TResult>(OneOf<T1, T2>, Func<T2, Result<TResult>>)
Binds the success value of a OneOf when T1 is an IError type. No error mapping needed - uses the IError directly.
public static Result<TResult> BindToResult<T1, T2, TResult>(this OneOf<T1, T2> oneOf, Func<T2, Result<TResult>> binder) where T1 : IError
Parameters
Returns
- Result<TResult>
Type Parameters
T1T2TResult
BindToResult<T1, T2, TResult>(OneOf<T1, T2>, Func<T2, Result<TResult>>, Func<T1, IError>?)
Binds the success value of a OneOf to a Result-producing function. Enables chaining OneOf values into Result workflows.
public static Result<TResult> BindToResult<T1, T2, TResult>(this OneOf<T1, T2> oneOf, Func<T2, Result<TResult>> binder, Func<T1, IError>? errorMapper = null)
Parameters
Returns
- Result<TResult>
Type Parameters
T1T2TResult
Filter<T1, T2>(OneOf<T1, T2>, Func<T2, bool>)
Filters a OneOf based on a predicate, returning the original OneOf if the predicate passes. Enables conditional processing in OneOf pipelines.
public static OneOf<T1, T2> Filter<T1, T2>(this OneOf<T1, T2> oneOf, Func<T2, bool> predicate)
Parameters
Returns
- OneOf<T1, T2>
Type Parameters
T1T2
SelectToResult<T1, T2, TResult>(OneOf<T1, T2>, Func<T2, TResult>)
Transforms the success value of a OneOf when T1 is an IError type. No error mapping needed - uses the IError directly.
public static Result<TResult> SelectToResult<T1, T2, TResult>(this OneOf<T1, T2> oneOf, Func<T2, TResult> selector) where T1 : IError
Parameters
Returns
- Result<TResult>
Type Parameters
T1T2TResult
SelectToResult<T1, T2, TResult>(OneOf<T1, T2>, Func<T2, TResult>, Func<T1, IError>?)
Transforms the success value of a OneOf using a selector function, returning a Result. Primary method with custom error mapping for maximum flexibility.
public static Result<TResult> SelectToResult<T1, T2, TResult>(this OneOf<T1, T2> oneOf, Func<T2, TResult> selector, Func<T1, IError>? errorMapper = null)
Parameters
Returns
- Result<TResult>
Type Parameters
T1T2TResult
ToOneOfCustom<T1, T2>(Result<T2>, Func<IReason, T1>)
Converts a Result to OneOf using custom error mapping. Alternative to the basic ToOneOf method with more flexible error handling.
public static OneOf<T1, T2> ToOneOfCustom<T1, T2>(this Result<T2> result, Func<IReason, T1> errorMapper)
Parameters
Returns
- OneOf<T1, T2>
Type Parameters
T1T2