OutcomeResilienceStrategy<T>
This base strategy class is used to simplify the implementation of generic (reactive)
strategies by limiting the number of generic types this strategy receives.
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Polly.Utils
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
internal abstract class OutcomeResilienceStrategy<[System.Runtime.CompilerServices.Nullable(2)] T> : ResilienceStrategy
{
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
0,
0,
1
})]
protected internal sealed 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)
{
if (context.ResultType == typeof(T)) {
Func<ResilienceContext, TState, ValueTask<Outcome<T>>> callback2 = (Func<ResilienceContext, TState, ValueTask<Outcome<T>>>)callback;
return TaskHelper.ConvertValueTask<T, TResult>(ExecuteCore(callback2, context, state), context);
}
return TaskHelper.ConvertValueTask<T, TResult>(ExecuteCore(delegate(ResilienceContext context, (Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback, TState state) state) {
<>c__0<TResult, TState>.<<ExecuteCore>b__0_0>d stateMachine = default(<>c__0<TResult, TState>.<<ExecuteCore>b__0_0>d);
stateMachine.<>t__builder = AsyncValueTaskMethodBuilder<Outcome<T>>.Create();
stateMachine.context = context;
stateMachine.state = state;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}, context, (callback, state)), context);
}
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
0,
0,
1
})]
protected abstract ValueTask<Outcome<T>> ExecuteCore<[System.Runtime.CompilerServices.Nullable(2)] TState>([System.Runtime.CompilerServices.Nullable(new byte[] {
1,
1,
1,
0,
0,
1
})] Func<ResilienceContext, TState, ValueTask<Outcome<T>>> callback, ResilienceContext context, TState state);
}
}