RetryPolicyState
using System;
using System.Threading;
using System.Threading.Tasks;
namespace Polly.Retry
{
internal class RetryPolicyState : IRetryPolicyState
{
private static readonly Task<bool> Done = Task.FromResult(true);
private readonly Action<Exception, Context> _onRetry;
private readonly Context _context;
public Task<bool> CanRetryAsync(Exception ex, CancellationToken ct, bool continueOnCapturedContext)
{
_onRetry(ex, _context);
return Done;
}
public RetryPolicyState(Action<Exception, Context> onRetry, Context context)
{
_onRetry = onRetry;
_context = context;
}
public RetryPolicyState(Action<Exception> onRetry)
: this(delegate(Exception exception, Context context) {
onRetry(exception);
}, null)
{
}
public bool CanRetry(Exception ex)
{
_onRetry(ex, _context);
return true;
}
}
}