private object InterceptAround(object currentInterceptor) { //invoke the next interceptor IAroundInterceptor interceptor = (IAroundInterceptor)currentInterceptor; Step++; return(interceptor.HandleCall(this)); }
public static object CreateAopProxy(Type proxyIntfaceType, object origin, IMethodInterceptor methodInterceptor, IAroundInterceptor aroundInterceptor) { lock (DynamicProxyFactory.AopProxyEmitter) { Type orignType = origin.GetType(); Type dynamicType = DynamicProxyFactory.AopProxyEmitter.EmitProxyType(proxyIntfaceType, orignType); //DynamicProxyFactory.AopProxyEmitter.Save(); ConstructorInfo ctor = dynamicType.GetConstructor(new Type[] { orignType, typeof(IMethodInterceptor), typeof(IAroundInterceptor) }); return(ctor.Invoke(new object[] { origin, methodInterceptor, aroundInterceptor })); } }
public static TInterface CreateAopProxy <TInterface>(TInterface origin, IMethodInterceptor methodInterceptor, IAroundInterceptor aroundInterceptor) { lock (DynamicProxyFactory.AopProxyEmitter) { Type orignType = typeof(TInterface); Type dynamicType = DynamicProxyFactory.AopProxyEmitter.EmitProxyType <TInterface>(orignType); //DynamicProxyFactory.AopProxyEmitter.Save(); ConstructorInfo ctor = dynamicType.GetConstructor(new Type[] { orignType, typeof(IMethodInterceptor), typeof(IAroundInterceptor) }); return((TInterface)ctor.Invoke(new object[] { origin, methodInterceptor, aroundInterceptor })); } }