コード例 #1
0
ファイル: RetryHandler.cs プロジェクト: zihaoccc/iKitchen
        public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext)
        {
            RetryAttribute retryAttribute = (RetryAttribute)input.MethodBase.GetCustomAttributes(typeof(RetryAttribute), false)[0];

            IMethodReturn returnValue = DoInvoke(input, getNext);

            if (returnValue.Exception != null && IsTypeMatch(returnValue.Exception.GetType(), retryAttribute))
            {
                if (retryTime >= retryAttribute.RetryMax)
                {
                    return(returnValue);
                }

                retryTime++;

                return(Invoke(input, getNext));
            }

            return(returnValue);
        }
コード例 #2
0
ファイル: RetryHandler.cs プロジェクト: zihaoccc/iKitchen
 private bool IsTypeMatch(Type exceptionType, RetryAttribute retryAttribute)
 {
     return(exceptionType == retryAttribute.Type ||
            exceptionType.IsSubclassOf(retryAttribute.Type));
 }