Class TraverseAllExtensions
- Namespace
- Trellis
- Assembly
- Trellis.Core.dll
Accumulating-error counterpart to Traverse<TIn, TOut>(IEnumerable<TIn>, Func<TIn, Result<TOut>>). Runs the selector over every item (no short-circuit) and folds failures via the existing Combine(Error?, Error) extension. Useful for form-style validation where every error matters, not just the first one encountered.
public static class TraverseAllExtensions
- Inheritance
-
TraverseAllExtensions
- Inherited Members
Methods
TraverseAllAsync<TIn>(IEnumerable<TIn>, Func<TIn, CancellationToken, Task<Result<Unit>>>, CancellationToken)
Asynchronously transforms a collection of items using a no-payload Result<Unit>
selector with cancellation support, accumulating failures via
Combine(Error?, Error). Mirrors
TraverseAsync<TIn>(IEnumerable<TIn>, Func<TIn, CancellationToken, Task<Result<Unit>>>, CancellationToken).
public static Task<Result<Unit>> TraverseAllAsync<TIn>(this IEnumerable<TIn> source, Func<TIn, CancellationToken, Task<Result<Unit>>> selector, CancellationToken cancellationToken = default)
Parameters
sourceIEnumerable<TIn>Source collection to transform.
selectorFunc<TIn, CancellationToken, Task<Result<Unit>>>Async no-payload selector with cancellation support.
cancellationTokenCancellationTokenCancellation token to observe. Cancellation throws OperationCanceledException and abandons accumulated state.
Returns
- Task<Result<Unit>>
Task producing success if all items succeed; otherwise a failure carrying the combined error.
Type Parameters
TInType of input items.
Exceptions
- ArgumentNullException
Thrown when
sourceorselectoris null.- OperationCanceledException
Thrown when
cancellationTokenis canceled.
TraverseAllAsync<TIn, TOut>(IEnumerable<TIn>, Func<TIn, CancellationToken, Task<Result<TOut>>>, CancellationToken)
Asynchronously transforms a collection of items, accumulating failures via Combine(Error?, Error). Supports cancellation. Mirrors TraverseAsync<TIn, TOut>(IEnumerable<TIn>, Func<TIn, CancellationToken, Task<Result<TOut>>>, CancellationToken).
public static Task<Result<IReadOnlyList<TOut>>> TraverseAllAsync<TIn, TOut>(this IEnumerable<TIn> source, Func<TIn, CancellationToken, Task<Result<TOut>>> selector, CancellationToken cancellationToken = default)
Parameters
sourceIEnumerable<TIn>Source collection to transform.
selectorFunc<TIn, CancellationToken, Task<Result<TOut>>>Async transformation function with cancellation support.
cancellationTokenCancellationTokenCancellation token to observe. Cancellation throws OperationCanceledException and abandons accumulated state.
Returns
- Task<Result<IReadOnlyList<TOut>>>
Task producing success with every transformed value if all items succeed; otherwise a failure carrying the combined error.
Type Parameters
TInType of input items.
TOutType of output items.
Exceptions
- ArgumentNullException
Thrown when
sourceorselectoris null.- OperationCanceledException
Thrown when
cancellationTokenis canceled.
TraverseAllAsync<TIn, TOut>(IEnumerable<TIn>, Func<TIn, CancellationToken, ValueTask<Result<TOut>>>, CancellationToken)
Asynchronously transforms a collection of items using ValueTask<TResult> with cancellation support, accumulating failures via Combine(Error?, Error). Mirrors TraverseAsync<TIn, TOut>(IEnumerable<TIn>, Func<TIn, CancellationToken, ValueTask<Result<TOut>>>, CancellationToken).
public static ValueTask<Result<IReadOnlyList<TOut>>> TraverseAllAsync<TIn, TOut>(this IEnumerable<TIn> source, Func<TIn, CancellationToken, ValueTask<Result<TOut>>> selector, CancellationToken cancellationToken = default)
Parameters
sourceIEnumerable<TIn>Source collection to transform.
selectorFunc<TIn, CancellationToken, ValueTask<Result<TOut>>>Async transformation function with cancellation support.
cancellationTokenCancellationTokenCancellation token to observe. Cancellation throws OperationCanceledException and abandons accumulated state.
Returns
- ValueTask<Result<IReadOnlyList<TOut>>>
ValueTask producing success with every transformed value if all items succeed; otherwise a failure carrying the combined error.
Type Parameters
TInType of input items.
TOutType of output items.
Exceptions
- ArgumentNullException
Thrown when
sourceorselectoris null.- OperationCanceledException
Thrown when
cancellationTokenis canceled.
TraverseAllAsync<TIn, TOut>(IEnumerable<TIn>, Func<TIn, Task<Result<TOut>>>)
Asynchronously transforms a collection of items into a Result containing all transformed items, accumulating failures via Combine(Error?, Error). Selectors are awaited sequentially (mirroring TraverseAsync<TIn, TOut>(IEnumerable<TIn>, Func<TIn, Task<Result<TOut>>>)).
public static Task<Result<IReadOnlyList<TOut>>> TraverseAllAsync<TIn, TOut>(this IEnumerable<TIn> source, Func<TIn, Task<Result<TOut>>> selector)
Parameters
sourceIEnumerable<TIn>Source collection to transform.
selectorFunc<TIn, Task<Result<TOut>>>Async transformation function returning a Result.
Returns
- Task<Result<IReadOnlyList<TOut>>>
Task producing success with every transformed value if all items succeed; otherwise a failure carrying the combined error.
Type Parameters
TInType of input items.
TOutType of output items.
Exceptions
- ArgumentNullException
Thrown when
sourceorselectoris null.
TraverseAllAsync<TIn, TOut>(IEnumerable<TIn>, Func<TIn, ValueTask<Result<TOut>>>)
Asynchronously transforms a collection of items using ValueTask<TResult>, accumulating failures via Combine(Error?, Error). Mirrors TraverseAsync<TIn, TOut>(IEnumerable<TIn>, Func<TIn, ValueTask<Result<TOut>>>).
public static ValueTask<Result<IReadOnlyList<TOut>>> TraverseAllAsync<TIn, TOut>(this IEnumerable<TIn> source, Func<TIn, ValueTask<Result<TOut>>> selector)
Parameters
sourceIEnumerable<TIn>Source collection to transform.
selectorFunc<TIn, ValueTask<Result<TOut>>>Async transformation function returning a Result.
Returns
- ValueTask<Result<IReadOnlyList<TOut>>>
ValueTask producing success with every transformed value if all items succeed; otherwise a failure carrying the combined error.
Type Parameters
TInType of input items.
TOutType of output items.
Exceptions
- ArgumentNullException
Thrown when
sourceorselectoris null.
TraverseAll<TIn, TOut>(IEnumerable<TIn>, Func<TIn, Result<TOut>>)
Transforms a collection of items into a Result containing all transformed items, accumulating any failures via Combine(Error?, Error). Unlike Traverse<TIn, TOut>(IEnumerable<TIn>, Func<TIn, Result<TOut>>), this method does not short-circuit: the selector is invoked for every item.
public static Result<IReadOnlyList<TOut>> TraverseAll<TIn, TOut>(this IEnumerable<TIn> source, Func<TIn, Result<TOut>> selector)
Parameters
sourceIEnumerable<TIn>Source collection to transform.
selectorFunc<TIn, Result<TOut>>Transformation function returning a Result.
Returns
- Result<IReadOnlyList<TOut>>
Success carrying every transformed value in source order if every item succeeds; otherwise a failure carrying the combined error. A single failure is returned unchanged (no Error.Aggregate wrap).
Type Parameters
TInType of input items.
TOutType of output items.
Exceptions
- ArgumentNullException
Thrown when
sourceorselectoris null.