/// <summary> /// Creates a new instance of the CallInterceptor class. /// </summary> /// <param name="interfaceType">Interface type of the intercepted component</param> /// <param name="uniqueName">Unique name of the intercepted component</param> /// <param name="memberType">Type of the intercepted member</param> /// <param name="memberName">Name of the intercepted member</param> /// <param name="parameterTypes">Types of parameters for the intercepted member</param> /// <param name="onInterception">Callback for custom call interception logic</param> public CallInterceptor(Type interfaceType, string uniqueName, MemberTypes memberType, string memberName, Type[] parameterTypes, CallInterceptionDelegate onInterception) { InterfaceType = interfaceType; UniqueName = string.IsNullOrEmpty(uniqueName) ? interfaceType.FullName : uniqueName; MemberType = memberType; MemberName = memberName; ParameterTypes = parameterTypes; OnInterception = onInterception; Enabled = true; }
/// <summary> /// Creates new CallInterceptor for the given method. /// </summary> /// <param name="expression">LINQ expression of the method to intercept.</param> /// <param name="handler">Interception handler.</param> public CallInterceptor Action(Expression <Action <T> > expression, CallInterceptionDelegate handler) { CheckNotNull(handler); MemberTypes memberType; string memberName; Parse(expression, out memberType, out memberName); return(new CallInterceptor(typeof(T), UniqueName, memberType, memberName, new Type[0], handler)); }
/// <summary> /// Creates new CallInterceptor for the given method and adds it to the interceptors collection. /// </summary> /// <param name="expression">LINQ expression of the method to intercept.</param> /// <param name="handler">Interception handler.</param> public CallInterceptorHelper <T> Add(Expression <Action <T> > expression, CallInterceptionDelegate handler) { CheckNotNull(handler); MemberTypes memberType; string memberName; Parse(expression, out memberType, out memberName); Interceptors.Add(new CallInterceptor(typeof(T), memberType, memberName, new Type[0], handler)); return(this); }
/// <summary> /// Creates a new instance of the CallInterceptor class. /// </summary> /// <param name="interfaceType">Interface type of the intercepted component</param> /// <param name="memberType">Type of the intercepted member</param> /// <param name="memberName">Name of the intercepted member</param> /// <param name="parameterTypes">Types of parameters for the intercepted member</param> /// <param name="onInterception">Callback for custom call interception logic</param> public CallInterceptor(Type interfaceType, MemberTypes memberType, string memberName, Type[] parameterTypes, CallInterceptionDelegate onInterception) : this(interfaceType, null, memberType, memberName, parameterTypes, onInterception) { }