public IAsyncPolicy <IContinuation> BuildPolicy(RetryPolicyCollection parent) { var policies = combine(parent).Reverse().ToArray(); if (policies.Length != 0) { return(policies.Length == 1 ? policies[0] : Policy.WrapAsync(policies)); } return(null); }
private IEnumerable <IAsyncPolicy <IContinuation> > combine(RetryPolicyCollection parent) { foreach (var policy in _policies) { yield return(policy); } if (MaximumAttempts.HasValue) { yield return(Policy <IContinuation> .Handle <Exception>().Requeue(MaximumAttempts.Value)); } foreach (var policy in parent._policies) { yield return(policy); } if (parent.MaximumAttempts.HasValue) { yield return(Policy <IContinuation> .Handle <Exception>().Requeue(parent.MaximumAttempts.Value)); } }