예제 #1
0
        public override MarshalByRefObject CreateInstance(Type serverType)
        {
            MarshalByRefObject target = base.CreateInstance(serverType);
            var rp = new DynamicProxy(target, serverType);

            rp.BeforeExecute  += (s, e) => TraceMethodStartLog(e);
            rp.AfterExecute   += (s, e) => TraceMethodEndLog(e);
            rp.ErrorExecuting += (s, e) => TraceErrorLog(e);
            //rp.Filter = m => !m.Name.StartsWith("Get");

            return(rp.GetTransparentProxy() as MarshalByRefObject);
        }
예제 #2
0
        public static IRepository <T> Create <T>()
        {
            var repository   = new Repository <T>();
            var dynamicProxy = new DynamicProxy <IRepository <T> >(repository);

            dynamicProxy.BeforeExecute += (s, e) => Log(
                "Before executing '{0}'", e.MethodName);
            dynamicProxy.AfterExecute += (s, e) => Log(
                "After executing '{0}'", e.MethodName);
            dynamicProxy.ErrorExecuting += (s, e) => Log(
                "Error executing '{0}'", e.MethodName);
            dynamicProxy.Filter = m => !m.Name.StartsWith("Get");
            return(dynamicProxy.GetTransparentProxy() as IRepository <T>);
        }