示例#1
0
        /// <summary>
        /// Specifies the type of exception that this policy can handle.
        /// </summary>
        /// <typeparam name="TException">The type of the exception to handle.</typeparam>
        /// <returns>The PolicyBuilder instance.</returns>
        public PolicyBuilder Or <TException>() where TException : Exception
        {
            ExceptionPredicate predicate = exception => exception is TException;

            ExceptionPredicates.Add(predicate);
            return(this);
        }
示例#2
0
        /// <summary>
        /// Specifies the type of exception that this policy can handle with additional filters on this exception type.
        /// </summary>
        /// <typeparam name="TException">The type of the exception.</typeparam>
        /// <param name="exceptionPredicate">The exception predicate to filter the type of exception this policy can handle.</param>
        /// <returns>The PolicyBuilder instance.</returns>
        public PolicyBuilder Or <TException>(Func <TException, bool> exceptionPredicate) where TException : Exception
        {
            ExceptionPredicate predicate = exception => exception is TException &&
                                           exceptionPredicate((TException)exception);

            ExceptionPredicates.Add(predicate);
            return(this);
        }
示例#3
0
 /// <summary>
 /// Specifies the type of exception that this policy can handle if found as an InnerException of a regular <see cref="Exception"/>, or at any level of nesting within an <see cref="AggregateException"/>.
 /// </summary>
 /// <typeparam name="TException">The type of the exception to handle.</typeparam>
 /// <returns>The PolicyBuilder instance, for fluent chaining.</returns>
 public PolicyBuilder OrInner <TException>() where TException : Exception
 {
     ExceptionPredicates.Add((HandleInner(ex => ex is TException)));
     return(this);
 }
示例#4
0
 internal PolicyBuilder(ExceptionPredicate exceptionPredicate)
 {
     ExceptionPredicates = new ExceptionPredicates();
     ExceptionPredicates.Add(exceptionPredicate);
 }
示例#5
0
 /// <summary>
 /// Specifies the type of exception that this policy can handle.
 /// </summary>
 /// <typeparam name="TException">The type of the exception to handle.</typeparam>
 /// <returns>The PolicyBuilder instance.</returns>
 public PolicyBuilder Or <TException>() where TException : Exception
 {
     ExceptionPredicates.Add(exception => exception is TException ? exception : null);
     return(this);
 }