private ITestObject CreateProxyChain(IAdvice interceptor, bool exposeProxy)
        {
            ITestObject first      = new ChainableTestObject(null);
            ITestObject firstProxy = CreateProxy(first, interceptor, exposeProxy);

            Assert.IsNotNull(firstProxy);

            ITestObject second      = new ChainableTestObject(firstProxy);
            ITestObject secondProxy = CreateProxy(second, interceptor, exposeProxy);

            Assert.IsNotNull(secondProxy);
            return(secondProxy);
        }
        public void ProxyPerformanceTests()
        {
            int       runs  = 5000000;
            StopWatch watch = new StopWatch();

            ITestObject testObject = new ChainableTestObject(null);

            using (watch.Start("Naked Duration: {0}"))
            {
                for (int i = 0; i < runs; i++)
                {
                    object result = testObject.DoSomething(this);
                }
            }

            ITestObject hardcodedWrapper = new ChainableTestObject(testObject);

            using (watch.Start("Hardcoded Wrapper Duration: {0}"))
            {
                for (int i = 0; i < runs; i++)
                {
                    object result = hardcodedWrapper.DoSomething(this);
                }
            }

            PeformanceTestAopContextInterceptor interceptor = new PeformanceTestAopContextInterceptor();
            ITestObject proxy = CreateProxy(testObject, interceptor, false);

            using (watch.Start("Proxy Duration ('ExposeProxy'==false): {0}"))
            {
                for (int i = 0; i < runs; i++)
                {
                    object result = proxy.DoSomething(this);
                }
            }
            Assert.AreEqual(runs, interceptor.Calls);

            interceptor = new PeformanceTestAopContextInterceptor();
            proxy       = CreateProxy(testObject, interceptor, true);
            using (watch.Start("Proxy Duration ('ExposeProxy'==true): {0}"))
            {
                for (int i = 0; i < runs; i++)
                {
                    object result = proxy.DoSomething(this);
                }
            }
            Assert.AreEqual(runs, interceptor.Calls);
        }
        private ITestObject CreateProxyChain(IAdvice interceptor, bool exposeProxy)
        {
            ITestObject first = new ChainableTestObject(null);
            ITestObject firstProxy = CreateProxy(first, interceptor, exposeProxy);
            Assert.IsNotNull(firstProxy);

            ITestObject second = new ChainableTestObject(firstProxy);
            ITestObject secondProxy = CreateProxy(second, interceptor, exposeProxy);
            Assert.IsNotNull(secondProxy);
            return secondProxy;
        }
        public void ProxyPerformanceTests()
        {
            int runs = 5000000;
            StopWatch watch = new StopWatch();

            ITestObject testObject = new ChainableTestObject(null);
            using (watch.Start("Naked Duration: {0}"))
            {
                for (int i = 0; i < runs; i++)
                {
                    object result = testObject.DoSomething(this);
                }
            }

            ITestObject hardcodedWrapper = new ChainableTestObject(testObject);
            using (watch.Start("Hardcoded Wrapper Duration: {0}"))
            {
                for (int i = 0; i < runs; i++)
                {
                    object result = hardcodedWrapper.DoSomething(this);
                }
            }

            PeformanceTestAopContextInterceptor interceptor = new PeformanceTestAopContextInterceptor();
            ITestObject proxy = CreateProxy(testObject, interceptor, false);
            using(watch.Start("Proxy Duration ('ExposeProxy'==false): {0}"))
            {
                for(int i=0;i<runs;i++)
                {
                    object result = proxy.DoSomething(this);
                }
            }
            Assert.AreEqual(runs, interceptor.Calls);

            interceptor = new PeformanceTestAopContextInterceptor();
            proxy = CreateProxy(testObject, interceptor, true);
            using(watch.Start("Proxy Duration ('ExposeProxy'==true): {0}"))
            {
                for(int i=0;i<runs;i++)
                {
                    object result = proxy.DoSomething(this);
                }
            }
            Assert.AreEqual(runs, interceptor.Calls);
        }