Пример #1
0
        /// <summary>
        /// Wraps the specified inner policy.
        /// </summary>
        /// <param name="innerPolicy">The inner policy.</param>
        /// <typeparam name="TResult">The return type of delegates which may be executed through the policy.</typeparam>
        /// <returns>PolicyWrap.PolicyWrap.</returns>
        public PolicyWrap <TResult> WrapAsync <TResult>(IAsyncPolicy <TResult> innerPolicy)
        {
            if (innerPolicy == null)
            {
                throw new ArgumentNullException(nameof(innerPolicy));
            }

            return(new PolicyWrap <TResult>(
                       (func, context, cancellationtoken, continueOnCapturedContext) => PolicyWrapEngine.ImplementationAsync <TResult>(func, context, cancellationtoken, continueOnCapturedContext, this, innerPolicy),
                       this,
                       innerPolicy
                       ));
        }
Пример #2
0
        /// <summary>
        /// Wraps the specified inner policy.
        /// </summary>
        /// <param name="innerPolicy">The inner policy.</param>
        /// <returns>PolicyWrap.PolicyWrap.</returns>
        public PolicyWrap WrapAsync(IAsyncPolicy innerPolicy)
        {
            if (innerPolicy == null)
            {
                throw new ArgumentNullException(nameof(innerPolicy));
            }

            return(new PolicyWrap(
                       (action, context, cancellationtoken, continueOnCapturedContext) => PolicyWrapEngine.ImplementationAsync(action, context, cancellationtoken, continueOnCapturedContext, this, innerPolicy),
                       this,
                       innerPolicy
                       ));
        }