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

BridgeComponentBase

using System; using System.Runtime.CompilerServices; using System.Threading.Tasks; namespace Polly.Utils.Pipeline { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] internal abstract class BridgeComponentBase : PipelineComponent { private readonly object _strategy; protected BridgeComponentBase(object strategy) { _strategy = strategy; } public override void Dispose() { IDisposable disposable = _strategy as IDisposable; if (disposable != null) disposable.Dispose(); else (_strategy as IAsyncDisposable)?.DisposeAsync().AsTask().GetAwaiter() .GetResult(); } public override ValueTask DisposeAsync() { IAsyncDisposable asyncDisposable = _strategy as IAsyncDisposable; if (asyncDisposable != null) return asyncDisposable.DisposeAsync(); Dispose(); return default(ValueTask); } } }