public void Handle(IExecutionPipelineContext context) { //在执行之前首先判断是否可以执行 if(!this.CanHandle(context)) return; //创建“Executing”事件参数 var executingArgs = new ExecutionPipelineExecutingEventArgs(context); //激发“Executing”事件 this.OnExecuting(executingArgs); if(executingArgs.Cancel) return; //执行过滤器的前半截 var filters = ExecutionUtility.InvokeFiltersExecuting(_filters, filter => filter.OnExecuting(context)); //执行当前处理请求 this.OnExecute(context); //执行过滤器的后半截 ExecutionUtility.InvokeFiltersExecuted(filters, filter => filter.OnExecuted(context)); //激发“Executed”事件 this.OnExecuted(new ExecutionPipelineExecutedEventArgs(context)); }
protected virtual void OnExecuting(ExecutionPipelineExecutingEventArgs e) { var executing = this.Executing; if(executing != null) executing(this, e); }
protected virtual void OnHandlerExecuting(ExecutionPipelineExecutingEventArgs args) { var executing = this.HandlerExecuting; if(executing != null) executing(this, args); }