static void DynamicInterceptorWithRegistry(object instance)
        {
            var interceptor = new DynamicInterceptor();
            var registry    = new RegistryInterceptionHandler();

            registry.Register <IMyType>(x => x.MyProperty, new MyHandler());
            registry.Register <IMyType>(x => x.MyMethod(), new MyHandler());
            dynamic myProxy = interceptor.Intercept(instance, null, registry);

            myProxy.MyMethod();
        }
        static void DynamicInterceptor(object instance)
        {
            //Dynamic interceptor
            var     interceptor      = new DynamicInterceptor();
            var     canIntercept     = interceptor.CanIntercept(instance);
            dynamic myProxy          = interceptor.Intercept(instance, null, new MyHandler());
            var     proxy            = myProxy as IInterceptionProxy;
            var     otherInterceptor = proxy.Interceptor;
            int     result           = myProxy.MyMethod();

            Assert.AreEqual(20, result);
        }
        public void CanDoDynamicInterceptionWithRegistry()
        {
            //interception through a registry
            var instance    = new MyType3();
            var interceptor = new DynamicInterceptor();
            var registry    = new RegistryInterceptionHandler()
                              .Register <MyType3>(x => x.MyProperty, new ModifyResultHandler())
                              .Register <MyType3>(x => x.MyMethod(), new ModifyResultHandler());
            dynamic myProxy = interceptor.Intercept(instance, typeof(IMyType), registry);
            var     result  = myProxy.MyMethod();

            Assert.Equal(20, result);
        }
        public void CanDoDynamicInterception()
        {
            var instance    = new MyType();
            var interceptor = new DynamicInterceptor();
            var handler     = new ModifyResultHandler();

            //dynamic proxy = this.InstanceInterception(interceptor, instance, handler);
            dynamic proxy = instance.InterceptDynamic(handler);

            var result = proxy.MyMethod();

            Assert.Equal(20, result);
        }
		static void DynamicInterceptor(object instance)
		{
			//Dynamic interceptor
			var interceptor = new DynamicInterceptor();
			var canIntercept = interceptor.CanIntercept(instance);
			dynamic myProxy = interceptor.Intercept(instance, null, new MyHandler());
			var proxy = myProxy as IInterceptionProxy;
			var otherInterceptor = proxy.Interceptor;
			int result = myProxy.MyMethod();
			Assert.AreEqual(20, result);
		}
		static void DynamicInterceptorWithRegistry(object instance)
		{
			var interceptor = new DynamicInterceptor();
			var registry = new RegistryInterceptionHandler();
			registry.Register<IMyType>(x => x.MyProperty, new MyHandler());
			registry.Register<IMyType>(x => x.MyMethod(), new MyHandler());
			dynamic myProxy = interceptor.Intercept(instance, null, registry);
			myProxy.MyMethod();
		}