<PackageReference Include="Polly.Core" Version="8.0.0-alpha.1" />

HedgingHandler<T>

sealed class HedgingHandler<T> : IEquatable<HedgingHandler<T>>
using Polly.Utils; using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; namespace Polly.Hedging.Utils { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] internal sealed class HedgingHandler<[System.Runtime.CompilerServices.Nullable(2)] T> : IEquatable<HedgingHandler<T>> { [CompilerGenerated] private Type EqualityContract { [CompilerGenerated] get { return typeof(HedgingHandler<T>); } } public PredicateInvoker<HandleHedgingArguments> ShouldHandle { get; set; } [System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0, 1, 2, 0, 0, 1 })] [field: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0, 1, 2, 0, 0, 1 })] public Func<HedgingActionGeneratorArguments<T>, Func<ValueTask<Outcome<T>>>> ActionGenerator { [return: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0, 1, 2, 0, 0, 1 })] get; [param: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0, 1, 2, 0, 0, 1 })] set; } public bool IsGeneric { get; set; } public HedgingHandler(PredicateInvoker<HandleHedgingArguments> ShouldHandle, [System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0, 1, 2, 0, 0, 1 })] Func<HedgingActionGeneratorArguments<T>, Func<ValueTask<Outcome<T>>>> ActionGenerator, bool IsGeneric) { ShouldHandle = ShouldHandle; ActionGenerator = ActionGenerator; IsGeneric = IsGeneric; base..ctor(); } [System.Runtime.CompilerServices.NullableContext(2)] public bool HandlesHedging<TResult>() { if (!this.IsGeneric) return true; return typeof(TResult) == typeof(T); } [System.Runtime.CompilerServices.NullableContext(2)] [return: System.Runtime.CompilerServices.Nullable(new byte[] { 2, 0, 0, 1 })] public Func<ValueTask<Outcome<TResult>>> GenerateAction<TResult>([System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] HedgingActionGeneratorArguments<TResult> args) { if (this.IsGeneric) { HedgingActionGeneratorArguments<T> arg = new HedgingActionGeneratorArguments<T>(args.Context, args.Attempt, (Func<ResilienceContext, ValueTask<Outcome<T>>>)args.Callback); return (Func<ValueTask<Outcome<TResult>>>)this.ActionGenerator(arg); } return CreateNonGenericAction(args); } [System.Runtime.CompilerServices.NullableContext(2)] [return: System.Runtime.CompilerServices.Nullable(new byte[] { 2, 0, 0, 1 })] private Func<ValueTask<Outcome<TResult>>> CreateNonGenericAction<TResult>([System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] HedgingActionGeneratorArguments<TResult> args) { Func<HedgingActionGeneratorArguments<object>, Func<ValueTask<Outcome<object>>>> func = (Func<HedgingActionGeneratorArguments<object>, Func<ValueTask<Outcome<object>>>>)this.ActionGenerator; <>c__DisplayClass17_0<TResult> <>4__this; Func<ValueTask<Outcome<object>>> action = func(new HedgingActionGeneratorArguments<object>(args.Context, args.Attempt, (Func<ResilienceContext, ValueTask<Outcome<object>>>)delegate(ResilienceContext context) { <>c__DisplayClass17_0<TResult>.<<CreateNonGenericAction>b__0>d stateMachine2 = default(<>c__DisplayClass17_0<TResult>.<<CreateNonGenericAction>b__0>d); stateMachine2.<>t__builder = AsyncValueTaskMethodBuilder<Outcome<object>>.Create(); stateMachine2.<>4__this = <>4__this; stateMachine2.context = context; stateMachine2.<>1__state = -1; stateMachine2.<>t__builder.Start(ref stateMachine2); return stateMachine2.<>t__builder.Task; })); if (action == null) return null; return delegate { <>c__DisplayClass17_0<TResult>.<<CreateNonGenericAction>b__1>d stateMachine = default(<>c__DisplayClass17_0<TResult>.<<CreateNonGenericAction>b__1>d); stateMachine.<>t__builder = AsyncValueTaskMethodBuilder<Outcome<TResult>>.Create(); stateMachine.<>4__this = <>4__this; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); return stateMachine.<>t__builder.Task; }; } [CompilerGenerated] public override string ToString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("HedgingHandler"); stringBuilder.Append(" { "); if (PrintMembers(stringBuilder)) stringBuilder.Append(' '); stringBuilder.Append('}'); return stringBuilder.ToString(); } [CompilerGenerated] private bool PrintMembers(StringBuilder builder) { RuntimeHelpers.EnsureSufficientExecutionStack(); builder.Append("ShouldHandle = "); builder.Append(ShouldHandle); builder.Append(", ActionGenerator = "); builder.Append(ActionGenerator); builder.Append(", IsGeneric = "); builder.Append(IsGeneric.ToString()); return true; } public static bool operator !=([System.Runtime.CompilerServices.Nullable(new byte[] { 2, 0 })] HedgingHandler<T> left, [System.Runtime.CompilerServices.Nullable(new byte[] { 2, 0 })] HedgingHandler<T> right) { return !(left == right); } public static bool operator ==([System.Runtime.CompilerServices.Nullable(new byte[] { 2, 0 })] HedgingHandler<T> left, [System.Runtime.CompilerServices.Nullable(new byte[] { 2, 0 })] HedgingHandler<T> right) { if ((object)left != right) return left?.Equals(right) ?? false; return true; } [CompilerGenerated] public override int GetHashCode() { return ((EqualityComparer<Type>.Default.GetHashCode(EqualityContract) * -1521134295 + EqualityComparer<PredicateInvoker<HandleHedgingArguments>>.Default.GetHashCode(ShouldHandle)) * -1521134295 + EqualityComparer<Func<HedgingActionGeneratorArguments<T>, Func<ValueTask<Outcome<T>>>>>.Default.GetHashCode(ActionGenerator)) * -1521134295 + EqualityComparer<bool>.Default.GetHashCode(IsGeneric); } [System.Runtime.CompilerServices.NullableContext(2)] [CompilerGenerated] public override bool Equals(object obj) { return Equals(obj as HedgingHandler<T>); } [CompilerGenerated] public bool Equals([System.Runtime.CompilerServices.Nullable(new byte[] { 2, 0 })] HedgingHandler<T> other) { if ((object)this != other) { if ((object)other != null && EqualityContract == other.EqualityContract && EqualityComparer<PredicateInvoker<HandleHedgingArguments>>.Default.Equals(ShouldHandle, other.ShouldHandle) && EqualityComparer<Func<HedgingActionGeneratorArguments<T>, Func<ValueTask<Outcome<T>>>>>.Default.Equals(ActionGenerator, other.ActionGenerator)) return EqualityComparer<bool>.Default.Equals(IsGeneric, other.IsGeneric); return false; } return true; } [CompilerGenerated] private HedgingHandler([System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0 })] HedgingHandler<T> original) { ShouldHandle = original.ShouldHandle; ActionGenerator = original.ActionGenerator; IsGeneric = original.IsGeneric; } [CompilerGenerated] public void Deconstruct(out PredicateInvoker<HandleHedgingArguments> ShouldHandle, [System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0, 1, 2, 0, 0, 1 })] out Func<HedgingActionGeneratorArguments<T>, Func<ValueTask<Outcome<T>>>> ActionGenerator, out bool IsGeneric) { ShouldHandle = this.ShouldHandle; ActionGenerator = this.ActionGenerator; IsGeneric = this.IsGeneric; } } }