DelegatingComponent
A component that delegates the execution to the next component in the chain.
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Polly.Utils.Pipeline
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
internal sealed class DelegatingComponent : PipelineComponent
{
private readonly PipelineComponent _component;
[System.Runtime.CompilerServices.Nullable(2)]
[field: System.Runtime.CompilerServices.Nullable(2)]
public PipelineComponent Next {
[System.Runtime.CompilerServices.NullableContext(2)]
get;
[System.Runtime.CompilerServices.NullableContext(2)]
set;
}
public DelegatingComponent(PipelineComponent component)
{
_component = component;
}
public override ValueTask DisposeAsync()
{
return default(ValueTask);
}
[ExcludeFromCodeCoverage]
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
0,
0,
1
})]
internal override ValueTask<Outcome<TResult>> ExecuteCore<[System.Runtime.CompilerServices.Nullable(2)] TResult, [System.Runtime.CompilerServices.Nullable(2)] TState>([System.Runtime.CompilerServices.Nullable(new byte[] {
1,
1,
1,
0,
0,
1
})] Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback, ResilienceContext context, TState state)
{
return ExecuteComponent(callback, context, state);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
0,
0,
1
})]
private static ValueTask<Outcome<TResult>> ExecuteNext<[System.Runtime.CompilerServices.Nullable(2)] TResult, [System.Runtime.CompilerServices.Nullable(2)] TState>(PipelineComponent next, [System.Runtime.CompilerServices.Nullable(new byte[] {
1,
1,
1,
0,
0,
1
})] Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback, ResilienceContext context, TState state)
{
if (context.CancellationToken.IsCancellationRequested)
return Outcome.FromExceptionAsValueTask<TResult>(new OperationCanceledException(context.CancellationToken).TrySetStackTrace());
return next.ExecuteCore(callback, context, state);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
0,
0,
1
})]
internal ValueTask<Outcome<TResult>> ExecuteComponent<[System.Runtime.CompilerServices.Nullable(2)] TResult, [System.Runtime.CompilerServices.Nullable(2)] TState>([System.Runtime.CompilerServices.Nullable(new byte[] {
1,
1,
1,
0,
0,
1
})] Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback, ResilienceContext context, TState state)
{
return _component.ExecuteCore((ResilienceContext context, (PipelineComponent Next, Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback, TState state) state) => DelegatingComponent.ExecuteNext<TResult, TState>(state.Next, state.callback, context, state.state), context, (Next, callback, state));
}
}
}