///// <summary> ///// 创建并返回当前方法的拦截器管道 ///// </summary> //public InterceptorPipeline CreatePipeline(MethodInfo method, Func<IEnumerable<IInterceptor>> getInterceptors) //{ // var key = InterceptorPipelineKey.ForMethod(method); // if (pipelines.ContainsKey(key)) // return pipelines[key]; // if (method.GetBaseDefinition() == method) // return pipelines[key] = new InterceptorPipeline(getInterceptors()); // return pipelines[key] = CreatePipeline(method.GetBaseDefinition(), getInterceptors); //} /// <summary> /// 创建并返回当前方法的拦截器管道 /// </summary> public InterceptorPipeline CreatePipeline(MethodInfo method, Func<MethodInfo, IEnumerable<IInterceptor>> getInterceptors) { var key = InterceptorPipelineKey.ForMethod(method); if(pipelines.ContainsKey(key)) return pipelines[key]; if(method.GetBaseDefinition() == method) return pipelines[key] = new InterceptorPipeline(getInterceptors(method)); return pipelines[key] = CreatePipeline(method.GetBaseDefinition(), getInterceptors); }
///// <summary> ///// 创建并返回当前方法的拦截器管道 ///// </summary> //public InterceptorPipeline CreatePipeline(MethodInfo method, Func<IEnumerable<IInterceptor>> getInterceptors) //{ // var key = InterceptorPipelineKey.ForMethod(method); // if (pipelines.ContainsKey(key)) // return pipelines[key]; // if (method.GetBaseDefinition() == method) // return pipelines[key] = new InterceptorPipeline(getInterceptors()); // return pipelines[key] = CreatePipeline(method.GetBaseDefinition(), getInterceptors); //} /// <summary> /// 创建并返回当前方法的拦截器管道 /// </summary> public InterceptorPipeline CreatePipeline(MethodInfo method, Func <MethodInfo, IEnumerable <IInterceptor> > getInterceptors) { var key = InterceptorPipelineKey.ForMethod(method); if (pipelines.ContainsKey(key)) { return(pipelines[key]); } if (method.GetBaseDefinition() == method) { return(pipelines[key] = new InterceptorPipeline(getInterceptors(method))); } return(pipelines[key] = CreatePipeline(method.GetBaseDefinition(), getInterceptors)); }
/// <summary> /// 设置当前方法的拦截器管道 /// </summary> public void SetPipeline(MethodBase method, InterceptorPipeline pipeline) { var key = InterceptorPipelineKey.ForMethod(method); pipelines[key] = pipeline; }