示例#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);
        }
示例#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));
            }
        }
示例#3
0
 internal PolicyExpression(RetryPolicyCollection parent, PolicyBuilder <IContinuation> builder)
 {
     _parent  = parent;
     _builder = builder;
 }