CompositeComponent
A combination of multiple components.
            
                using Polly.Telemetry;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Polly.Utils.Pipeline
{
    [System.Runtime.CompilerServices.NullableContext(1)]
    [System.Runtime.CompilerServices.Nullable(0)]
    [DebuggerDisplay("Pipeline, Strategies = {Components.Count}")]
    [DebuggerTypeProxy(typeof(CompositeComponentDebuggerProxy))]
    internal sealed class CompositeComponent : PipelineComponent
    {
        private readonly ResilienceStrategyTelemetry _telemetry;
        private readonly TimeProvider _timeProvider;
        internal PipelineComponent FirstComponent { get; }
        public IReadOnlyList<PipelineComponent> Components { get; }
        private CompositeComponent(PipelineComponent first, IReadOnlyList<PipelineComponent> components, ResilienceStrategyTelemetry telemetry, TimeProvider timeProvider)
        {
            Components = components;
            _telemetry = telemetry;
            _timeProvider = timeProvider;
            FirstComponent = first;
        }
        public static PipelineComponent Create(IReadOnlyList<PipelineComponent> components, ResilienceStrategyTelemetry telemetry, TimeProvider timeProvider)
        {
            if (components.Count == 1)
                return new CompositeComponent(components[0], components, telemetry, timeProvider);
            DelegatingComponent[] array = (from strategy in components.Take(components.Count - 1)
            select new DelegatingComponent(strategy)).ToArray();
            array[array.Length - 1].Next = components[components.Count - 1];
            for (int i = 0; i < array.Length - 1; i++) {
                array[i].Next = array[i + 1];
            }
            return new CompositeComponent(array[0], components, telemetry, timeProvider);
        }
        [AsyncStateMachine(typeof(<DisposeAsync>d__10))]
        public override ValueTask DisposeAsync()
        {
            <DisposeAsync>d__10 stateMachine = default(<DisposeAsync>d__10);
            stateMachine.<>t__builder = AsyncValueTaskMethodBuilder.Create();
            stateMachine.<>4__this = this;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        [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)
        {
            if (!_telemetry.Enabled)
                return ExecuteCoreWithoutTelemetry(callback, context, state);
            return ExecuteCoreWithTelemetry(callback, context, state);
        }
        [return: System.Runtime.CompilerServices.Nullable(new byte[] {
            0,
            0,
            1
        })]
        private ValueTask<Outcome<TResult>> ExecuteCoreWithoutTelemetry<[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.CancellationToken.IsCancellationRequested)
                return Outcome.FromExceptionAsValueTask<TResult>(new OperationCanceledException(context.CancellationToken).TrySetStackTrace());
            return FirstComponent.ExecuteCore(callback, context, state);
        }
        [AsyncStateMachine(typeof(<ExecuteCoreWithTelemetry>d__13<, >))]
        [return: System.Runtime.CompilerServices.Nullable(new byte[] {
            0,
            0,
            1
        })]
        private ValueTask<Outcome<TResult>> ExecuteCoreWithTelemetry<[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)
        {
            <ExecuteCoreWithTelemetry>d__13<TResult, TState> stateMachine = default(<ExecuteCoreWithTelemetry>d__13<TResult, TState>);
            stateMachine.<>t__builder = AsyncValueTaskMethodBuilder<Outcome<TResult>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.callback = callback;
            stateMachine.context = context;
            stateMachine.state = state;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
    }
}