/// <summary>
 /// Invoke all modules
 /// </summary>
 /// <param name="context"></param>
 /// <returns><c>true</c> if no modules have aborted the handling. Any module throwing an exception is also considered to be abort.</returns>
 public void InvokeAsync(IHttpContext context, AsyncModuleHandler callback)
 {
     var canContinue = HandleBeginRequest(context);
     if (canContinue)
         canContinue = InvokeModules(context, _authenticationModules, InvokeAuthenticate);
     if (canContinue)
         canContinue = InvokeModules(context, _routingModules, InvokeRouting);
     if (canContinue)
         canContinue = InvokeModules(context, _authorizationModules, InvokeAuthorize);
     if (canContinue)
     {
         var modules = _workerModules.GetEnumerator();
         if (modules.MoveNext())
         {
             ((IWorkerModule)modules.Current).HandleRequestAsync(context,
                                                result => InvokeNextWorker(result, modules, innerResult =>
                                                    {
                                                        HandleEndRequest(context);
                                                        callback(innerResult);
                                                    }));
         }
         else
         {
             callback(new AsyncModuleResult(context, ModuleResult.Continue));
         }
     }
     else
     {
         HandleEndRequest(context);
         callback(new AsyncModuleResult(context, ModuleResult.Stop));
     }
 }
        /// <summary>
        /// Invoke all modules
        /// </summary>
        /// <param name="context"></param>
        /// <returns><c>true</c> if no modules have aborted the handling. Any module throwing an exception is also considered to be abort.</returns>
        public void InvokeAsync(IHttpContext context, AsyncModuleHandler callback)
        {
            var canContinue = HandleBeginRequest(context);

            if (canContinue)
            {
                canContinue = InvokeModules(context, _authenticationModules, InvokeAuthenticate);
            }
            if (canContinue)
            {
                canContinue = InvokeModules(context, _routingModules, InvokeRouting);
            }
            if (canContinue)
            {
                canContinue = InvokeModules(context, _authorizationModules, InvokeAuthorize);
            }
            if (canContinue)
            {
                var modules = _workerModules.GetEnumerator();
                if (modules.MoveNext())
                {
                    ((IWorkerModule)modules.Current).HandleRequestAsync(context,
                                                                        result => InvokeNextWorker(result, modules, innerResult =>
                    {
                        HandleEndRequest(context);
                        callback(innerResult);
                    }));
                }
                else
                {
                    callback(new AsyncModuleResult(context, ModuleResult.Continue));
                }
            }
            else
            {
                HandleEndRequest(context);
                callback(new AsyncModuleResult(context, ModuleResult.Stop));
            }
        }
        private void InvokeNextWorker(IAsyncModuleResult result, IEnumerator modules, AsyncModuleHandler callback)
        {
            if (result.Result == ModuleResult.Stop)
            {
                callback(result);
                return;
            }

            if (modules.MoveNext())
            {
                try
                {
                    ((IWorkerModule)modules.Current).HandleRequestAsync(result.Context, x => InvokeNextWorker(x, modules, callback));
                }
                catch (Exception err)
                {
                    result.Exception = err;
                    result.Result = ModuleResult.Stop;
                    callback(result);
                }
            }
            else
            {
                callback(result);
            }
        }
 /// <summary>
 /// Handle the request asynchronously.
 /// </summary>
 /// <param name="context">HTTP context</param>
 /// <param name="callback">callback</param>
 /// <returns><see cref="ModuleResult.Stop"/> will stop all processing except <see cref="IHttpModule.EndRequest"/>.</returns>
 /// <remarks>Invoked in turn for all modules unless you return <see cref="ModuleResult.Stop"/>.</remarks>
 public void HandleRequestAsync(IHttpContext context, AsyncModuleHandler callback)
 {
     //Logger.WriteDebug(this, "Pipeline => HandleRequestAsync");
     callback(new AsyncModuleResult(context, HandleRequest(context)));
 }
Exemple #5
0
 /// <summary>
 /// Handle the request asynchronously.
 /// </summary>
 /// <param name="context">HTTP context</param>
 /// <param name="callback">callback</param>
 /// <returns><see cref="ModuleResult.Stop"/> will stop all processing except <see cref="IHttpModule.EndRequest"/>.</returns>
 /// <remarks>Invoked in turn for all modules unless you return <see cref="ModuleResult.Stop"/>.</remarks>
 public void HandleRequestAsync(IHttpContext context, AsyncModuleHandler callback)
 {
     callback(new AsyncModuleResult(context, HandleRequest(context)));
 }
 /// <summary>
 /// Handle the request asynchronously.
 /// </summary>
 /// <param name="context">HTTP context</param>
 /// <param name="callback">callback</param>
 /// <returns><see cref="ModuleResult.Stop"/> will stop all processing except <see cref="IHttpModule.EndRequest"/>.</returns>
 /// <remarks>Invoked in turn for all modules unless you return <see cref="ModuleResult.Stop"/>.</remarks>
 public void HandleRequestAsync(IHttpContext context, AsyncModuleHandler callback)
 {
     callback(new AsyncModuleResult(context, HandleRequest(context)));
 }
 /// <summary>
 /// Handle the request asynchronously.
 /// </summary>
 /// <param name="context">HTTP context</param>
 /// <param name="callback">callback</param>
 /// <returns><see cref="ModuleResult.Stop"/> will stop all processing except <see cref="IHttpModule.EndRequest"/>.</returns>
 /// <remarks>Invoked in turn for all modules unless you return <see cref="ModuleResult.Stop"/>.</remarks>
 public void HandleRequestAsync(IHttpContext context, AsyncModuleHandler callback)
 {
     //Logger.WriteDebug(this, "Pipeline => HandleRequestAsync");
     callback(new AsyncModuleResult(context, HandleRequest(context)));
 }
        private void InvokeNextWorker(IAsyncModuleResult result, IEnumerator modules, AsyncModuleHandler callback)
        {
            if (result.Result == ModuleResult.Stop)
            {
                callback(result);
                return;
            }

            if (modules.MoveNext())
            {
                try
                {
                    ((IWorkerModule)modules.Current).HandleRequestAsync(result.Context, x => InvokeNextWorker(x, modules, callback));
                }
                catch (Exception err)
                {
                    result.Exception = err;
                    result.Result    = ModuleResult.Stop;
                    callback(result);
                }
            }
            else
            {
                callback(result);
            }
        }