public IMessage SyncProcessMessage(IMessage msg) { var mcm = (msg as IMethodCallMessage); var mrm = null as IMethodReturnMessage; var handler = ContextBoundObjectInterceptor.GetInterceptor(this.Target); if (handler != null) { var arg = new InterceptionArgs(this.Target, mcm.MethodBase as MethodInfo, mcm.Args); try { handler.Invoke(arg); if (arg.Handled == true) { mrm = new ReturnMessage(arg.Result, new object[0], 0, mcm.LogicalCallContext, mcm); } } catch (Exception ex) { mrm = new ReturnMessage(ex, mcm); } } if (mrm == null) { mrm = this.NextSink.SyncProcessMessage(msg) as IMethodReturnMessage; } return(mrm); }
public IMessage SyncProcessMessage(IMessage msg) { var mcm = (msg as IMethodCallMessage); var mrm = null as IMethodReturnMessage; var handler = ContextBoundObjectInterceptor.GetInterceptor(this.Target); if (handler != null) { var arg = new InterceptionArgs(this.Target, mcm.MethodBase as MethodInfo, mcm.Args); try { handler.Invoke(arg); if (arg.Handled == true) { mrm = new ReturnMessage(arg.Result, new object[0], 0, mcm.LogicalCallContext, mcm); } } catch (Exception ex) { mrm = new ReturnMessage(ex, mcm); } } if (mrm == null) { mrm = this.NextSink.SyncProcessMessage(msg) as IMethodReturnMessage; } return mrm; }
public void Invoke(InterceptionArgs arg) { if (this.condition(arg) == true) { this.handler.Invoke(arg); } }
public void Invoke(InterceptionArgs arg) { var attrs = arg.Method.GetCustomAttributes(true).OfType <InterceptionAttribute>().OrderBy(x => x.Order).Cast <IInterceptionHandler>(); foreach (var attr in attrs) { attr.Invoke(arg); } }
public void Invoke(InterceptionArgs arg) { EventHandler<InterceptionArgs> handler = this.Interception; if (handler != null) { handler(this, arg); } }
public void Invoke(InterceptionArgs arg) { IInterceptionHandler handler; if (this.handlers.TryGetValue(arg.Method, out handler) == true) { handler.Invoke(arg); } }
public void Invoke(InterceptionArgs arg) { EventHandler <InterceptionArgs> handler = this.Interception; if (handler != null) { handler(this, arg); } }
public void Invoke(InterceptionArgs arg) { var attrs = arg.Method.GetCustomAttributes(true).OfType<InterceptionAttribute>().OrderBy(x => x.Order).Cast<IInterceptionHandler>(); foreach (var attr in attrs) { attr.Invoke(arg); } }
public void Invoke(InterceptionArgs arg) { for (var i = 0; i < this.Handlers.Count; ++i) { this.Handlers[i].Invoke(arg); if (arg.Handled == true) { break; } } }
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) { var method = this.target.GetType().GetMethod(binder.Name); var arg = new InterceptionArgs(this.target, method, args); this.handler.Invoke(arg); if (arg.Handled == true) { result = arg.Result; } else { result = method.Invoke(this.target, args); } return true; }
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) { var method = this.target.GetType().GetMethod(binder.Name); var arg = new InterceptionArgs(this.target, method, args); this.handler.Invoke(arg); if (arg.Handled == true) { result = arg.Result; } else { result = method.Invoke(this.target, args); } return(true); }
public abstract void Invoke(InterceptionArgs arg);
public override IMessage Invoke(IMessage msg) { ReturnMessage responseMessage; object response = null; Exception caughtException = null; try { var methodName = msg.Properties["__MethodName"] as string; var parameterTypes = msg.Properties["__MethodSignature"] as Type[]; var parameters = msg.Properties["__Args"] as object[]; var typeName = msg.Properties["__TypeName"] as string; var method = this.instance.GetType().GetMethod(methodName, parameterTypes); if (method == null) { if (methodName.StartsWith("get_") == true) { var property = this.instance.GetType().GetProperty(methodName.Substring(4), BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (property != null) { method = property.GetGetMethod(); } else { if ((methodName == "get_Interceptor") && (typeName == typeof(IInterceptionProxy).AssemblyQualifiedName)) { return(new ReturnMessage(this.interceptor, null, 0, null, msg as IMethodCallMessage)); } } } } var args = new InterceptionArgs(this.instance, method, parameters); this.handler.Invoke(args); if (args.Handled == false) { args.Proceed(); } response = args.Result; } catch (Exception ex) { caughtException = ex; } var message = msg as IMethodCallMessage; if (caughtException == null) { responseMessage = new ReturnMessage(response, null, 0, null, message); } else { responseMessage = new ReturnMessage(caughtException, message); } return(responseMessage); }
public override IMessage Invoke(IMessage msg) { ReturnMessage responseMessage; object response = null; Exception caughtException = null; try { var methodName = msg.Properties["__MethodName"] as string; var parameterTypes = msg.Properties["__MethodSignature"] as Type[]; var parameters = msg.Properties["__Args"] as object[]; var typeName = msg.Properties["__TypeName"] as string; var method = this.instance.GetType().GetMethod(methodName, parameterTypes); if (method == null) { if (methodName.StartsWith("get_") == true) { var property = this.instance.GetType().GetProperty(methodName.Substring(4), BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (property != null) { method = property.GetGetMethod(); } else { if ((methodName == "get_Interceptor") && (typeName == typeof(IInterceptionProxy).AssemblyQualifiedName)) { return (new ReturnMessage(this.interceptor, null, 0, null, msg as IMethodCallMessage)); } } } } var args = new InterceptionArgs(this.instance, method, parameters); this.handler.Invoke(args); if (args.Handled == false) { args.Proceed(); } response = args.Result; } catch (Exception ex) { caughtException = ex; } var message = msg as IMethodCallMessage; if (caughtException == null) { responseMessage = new ReturnMessage(response, null, 0, null, message); } else { responseMessage = new ReturnMessage(caughtException, message); } return (responseMessage); }