Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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));
            }
        }
Esempio n. 3
0
 internal PolicyExpression(RetryPolicyCollection parent, PolicyBuilder <IContinuation> builder)
 {
     _parent  = parent;
     _builder = builder;
 }