private void PostInterception( object target, Method method, ParameterAndValue[] parameters, PreVerbExecutionContext preVerbExecutionContext, Exception verbException) { var postVerbExecutionContext = new PostVerbExecutionContext( method, target, parameters, preVerbExecutionContext.Cancel, verbException, preVerbExecutionContext.UserContext); // registered interceptors get top priority // if (m_registration.RegisteredPostVerbInterceptor != null) { m_registration.RegisteredPostVerbInterceptor(postVerbExecutionContext); } else { var postInterceptionMethods = Type.GetMethodsWith <PostVerbExecutionAttribute>(); // try a defined interceptor type // if (postInterceptionMethods.Any()) { Debug.Assert(postInterceptionMethods.Count() == 1); var postInterceptionMethod = postInterceptionMethods.First(); MethodInvoker.Invoke(postInterceptionMethod, target, new[] { postVerbExecutionContext }); } else { // try a defined interceptor type // if (Type.HasAttribute <VerbInterception>()) { var interception = Type.GetAttribute <VerbInterception>(); var interceptor = (IPostVerbInterceptor)Activator.CreateInstance(interception.InterceptorType); interceptor.AfterVerbExecution(postVerbExecutionContext); } } } }
private PreVerbExecutionContext PreInterception( object target, Method method, ParameterAndValue[] parameters) { var preVerbExecutionContext = new PreVerbExecutionContext(method, target, parameters); // registered interceptors get top priority // if (m_registration.RegisteredPreVerbInterceptor != null) { m_registration.RegisteredPreVerbInterceptor(preVerbExecutionContext); } else { // try a defined verb interceptor // var preInterceptionMethods = Type.GetMethodsWith <PreVerbExecutionAttribute>(); if (preInterceptionMethods.Any()) { Debug.Assert(preInterceptionMethods.Count() == 1); var preInterceptionMethod = preInterceptionMethods.First(); MethodInvoker.Invoke(preInterceptionMethod, target, new[] { preVerbExecutionContext }); } else { // try a defined interceptor type // if (Type.HasAttribute <VerbInterception>()) { var interception = Type.GetAttribute <VerbInterception>(); var interceptor = (IPreVerbInterceptor)Activator.CreateInstance(interception.InterceptorType); interceptor.BeforeVerbExecution(preVerbExecutionContext); } } } return(preVerbExecutionContext); }
private void Pre(PreVerbExecutionContext context) { PreContext = context; context.UserContext.Add("a", 54); }
static void Pre(PreVerbExecutionContext x, string y) { }
public void BeforeVerbExecution(PreVerbExecutionContext context) { PreContext = context; context.UserContext.Add("a", 54); }
private void Pre2(PreVerbExecutionContext context) { }
private void Pre(PreVerbExecutionContext context) { PreContext = context; context.Cancel = true; }