示例#1
0
        protected virtual void OnExecuting(ExecutingEventArgs args)
        {
            var executing = this.Executing;

            if (executing != null)
            {
                executing(this, args);
            }
        }
示例#2
0
        protected ExecutionResult Execute(IExecutionContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            //创建“Executing”事件的调用参数
            ExecutingEventArgs executingArgs = new ExecutingEventArgs(context);

            //激发“Executing”事件
            this.OnExecuting(executingArgs);

            if (executingArgs.Cancel)
            {
                return(new ExecutionResult(context));
            }

            //通过选择器获取当前请求对应的管道集
            var pipelines = this.SelectPipelines(context, _pipelines);

            //如果当前执行的处理管道数为零则退出
            if (pipelines == null || pipelines.Count() < 1)
            {
                return(null);
            }

            //调用执行器过滤器的前半截
            var stack = ExecutionUtility.InvokeFiltersExecuting(context.Executor.Filters, filter => this.OnFilterExecuting(filter, context));

            //执行管道集,并将其执行的最终结果保存到执行器上下文的Result属性中
            context.Result = this.InvokePipelines(pipelines, p => this.CreatePipelineContext(context, p, context.Parameter));

            //调用执行器过滤器的后半截
            ExecutionUtility.InvokeFiltersExecuted(stack, filter => this.OnFilterExecuted(filter, context));

            //激发“Executed”事件
            this.OnExecuted(new ExecutedEventArgs(context));

            return(new ExecutionResult(context));
        }