private async Task <TResult> PerformRun(
            Func <CancellationToken, Task <TResult> > operation,
            CancellationToken cancellationToken)
        {
            int     retryCount = 0;
            TResult result     = default;

Try:
            try
            {
                result = await operation.Invoke(cancellationToken).ConfigureAwait(false);
            }
            catch (Exception exception)
                when(TransientFaultDetectionStrategy.IsTransientException(exception) && retryCount < MaximumRetryCount)
                {
                    await Task.Delay(RetryIntervalStrategy.GetInterval(retryCount));

                    retryCount++;
                    goto Try;
                }

            if (TransientFaultDetectionStrategy.IsTransientResult(result) &&
                retryCount < MaximumRetryCount)
            {
                await Task.Delay(RetryIntervalStrategy.GetInterval(retryCount));

                retryCount++;
                goto Try;
            }

            return(result);
        }
 public RetryPolicy(
     int maximumRetryCount,
     TransientFaultDetectionStrategy <TResult> transientFaultDetectionStrategy,
     RetryIntervalStrategy retryIntervalStrategy)
     : base(maximumRetryCount, transientFaultDetectionStrategy, retryIntervalStrategy)
 {
     TransientFaultDetectionStrategy = transientFaultDetectionStrategy;
 }
        public RetryPolicy(
            int maximumRetryCount,
            TransientFaultDetectionStrategy transientFaultDetectionStrategy,
            RetryIntervalStrategy retryIntervalStrategy)
        {
            if (maximumRetryCount < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(maximumRetryCount), "Value cannot be negative.");
            }

            MaximumRetryCount = maximumRetryCount;
            TransientFaultDetectionStrategy = transientFaultDetectionStrategy ?? throw new ArgumentNullException(nameof(transientFaultDetectionStrategy));
            RetryIntervalStrategy           = retryIntervalStrategy ?? throw new ArgumentNullException(nameof(retryIntervalStrategy));
        }