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

oneOf OneOf<T1, T2>
binder Func<T2, Result<TResult>>

Returns

Result<TResult>

Type Parameters

T1
T2
TResult

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

oneOf OneOf<T1, T2>
binder Func<T2, Result<TResult>>
errorMapper Func<T1, IError>

Returns

Result<TResult>

Type Parameters

T1
T2
TResult

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

oneOf OneOf<T1, T2>
predicate Func<T2, bool>

Returns

OneOf<T1, T2>

Type Parameters

T1
T2

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

oneOf OneOf<T1, T2>
selector Func<T2, TResult>

Returns

Result<TResult>

Type Parameters

T1
T2
TResult

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

oneOf OneOf<T1, T2>
selector Func<T2, TResult>
errorMapper Func<T1, IError>

Returns

Result<TResult>

Type Parameters

T1
T2
TResult

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

result Result<T2>
errorMapper Func<IReason, T1>

Returns

OneOf<T1, T2>

Type Parameters

T1
T2