/// <summary>
        /// Using <see cref="CreateBehaviors"/>, behaviors are created. Then calling <see cref="CreateBehaviorContext"/> context is created. And then pipeline is executed.
        /// </summary>
        /// <param name="handler">Handler instance to execute pipeline on.</param>
        /// <param name="customValues">Collection of custom values passed around invokation.</param>
        /// <returns>Continuation task.</returns>
        public Task ExecuteAsync(T handler, IKeyValueCollection customValues)
        {
            IEnumerable <IBehavior <T> > behaviors = CreateBehaviors();
            IBehaviorContext             context   = CreateBehaviorContext(behaviors, handler, customValues);

            return(context.NextAsync());
        }
예제 #2
0
        private Task ExecuteAsync(object handler, IBehaviorContext context, int remaingCount)
        {
            IBehaviorContext contextState = context.Clone();

            try
            {
                return(context.NextAsync());
            }
            catch (Exception e)
            {
                remaingCount--;
                if (remaingCount > 0)
                {
                    int delay = (int)deplayBeforeReprocess.TotalMilliseconds;
                    if (delay > 0)
                    {
                        Thread.Sleep(delay);
                    }

                    Task result = ExecuteAsync(handler, contextState, remaingCount);
                    //context.CustomValues = contextState.CustomValues;
                    return(result);
                }

                throw e;
            }
        }
        public async Task ExecuteAsync(object handler, IBehaviorContext context)
        {
            int count = 0;

            while (true)
            {
                try
                {
                    await context.NextAsync();

                    break;
                }
                catch (Exception)
                {
                    count++;
                }
            }
        }
예제 #4
0
 public Task ExecuteAsync(object handler, IBehaviorContext context)
 {
     Console.WriteLine("Executing method on '{0}'.", handler.GetType().FullName);
     return(context.NextAsync());
 }
예제 #5
0
 public Task ExecuteAsync(object handler, IBehaviorContext context)
 {
     return(context.NextAsync());
 }
예제 #6
0
 public Task ExecuteAsync(Target1 handler, IBehaviorContext context)
 {
     handler.Test1 = true;
     return(context.NextAsync());
 }