RegistryPipelineComponentBuilder<TBuilder, TKey>
sealed class RegistryPipelineComponentBuilder<TBuilder, TKey> where TBuilder : ResiliencePipelineBuilderBase
Builds a PipelineComponent used by the registry.
using Polly.Telemetry;
using Polly.Utils.Pipeline;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;
namespace Polly.Registry
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
internal sealed class RegistryPipelineComponentBuilder<[System.Runtime.CompilerServices.Nullable(0)] TBuilder, TKey> where TBuilder : ResiliencePipelineBuilderBase
{
private readonly Func<TBuilder> _activator;
private readonly TKey _key;
private readonly string _builderName;
[System.Runtime.CompilerServices.Nullable(2)]
private readonly string _instanceName;
private readonly Action<TBuilder, ConfigureBuilderContext<TKey>> _configure;
public RegistryPipelineComponentBuilder(Func<TBuilder> activator, TKey key, string builderName, [System.Runtime.CompilerServices.Nullable(2)] string instanceName, Action<TBuilder, ConfigureBuilderContext<TKey>> configure)
{
_activator = activator;
_key = key;
_builderName = builderName;
_instanceName = instanceName;
_configure = configure;
}
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
0,
2,
1
})]
internal (ResilienceContextPool ContextPool, PipelineComponent Component) CreateComponent()
{
(PipelineComponent Component, List<CancellationToken> ReloadTokens, ResilienceStrategyTelemetry Telemetry, TBuilder Instance) valueTuple = CreateBuilder();
PipelineComponent item = valueTuple.Component;
List<CancellationToken> item2 = valueTuple.ReloadTokens;
ResilienceStrategyTelemetry item3 = valueTuple.Telemetry;
TBuilder item4 = valueTuple.Instance;
if (item2.Count == 0)
return (item4.ContextPool, item);
item = PipelineComponentFactory.CreateReloadable(new ReloadableComponent.Entry(item, item2, item3), delegate {
(PipelineComponent Component, List<CancellationToken> ReloadTokens, ResilienceStrategyTelemetry Telemetry, TBuilder Instance) valueTuple2 = CreateBuilder();
PipelineComponent item5 = valueTuple2.Component;
List<CancellationToken> item6 = valueTuple2.ReloadTokens;
ResilienceStrategyTelemetry item7 = valueTuple2.Telemetry;
return new ReloadableComponent.Entry(item5, item6, item7);
});
return (item4.ContextPool, item);
}
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
1,
1,
1
})]
private (PipelineComponent Component, List<CancellationToken> ReloadTokens, ResilienceStrategyTelemetry Telemetry, TBuilder Instance) CreateBuilder()
{
ConfigureBuilderContext<TKey> configureBuilderContext = new ConfigureBuilderContext<TKey>(_key, _builderName, _instanceName);
TBuilder val = _activator();
val.Name = _builderName;
val.InstanceName = _instanceName;
_configure(val, configureBuilderContext);
TimeProvider timeProviderInternal = val.TimeProviderInternal;
ResilienceStrategyTelemetry item = new ResilienceStrategyTelemetry(new ResilienceTelemetrySource(val.Name, val.InstanceName, null), val.TelemetryListener);
return (PipelineComponentFactory.WithExecutionTracking(PipelineComponentFactory.WithDisposableCallbacks(val.BuildPipelineComponent(), configureBuilderContext.DisposeCallbacks), timeProviderInternal), configureBuilderContext.ReloadTokens, item, val);
}
}
}