當前位置: 首頁>>代碼示例>>C#>>正文


C# ProxyFactory.RemoveAdvisor方法代碼示例

本文整理匯總了C#中Spring.Aop.Framework.ProxyFactory.RemoveAdvisor方法的典型用法代碼示例。如果您正苦於以下問題:C# ProxyFactory.RemoveAdvisor方法的具體用法?C# ProxyFactory.RemoveAdvisor怎麽用?C# ProxyFactory.RemoveAdvisor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Spring.Aop.Framework.ProxyFactory的用法示例。


在下文中一共展示了ProxyFactory.RemoveAdvisor方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RemoveAdvisorByReference

 public void RemoveAdvisorByReference()
 {
     TestObject target = new TestObject();
     ProxyFactory pf = new ProxyFactory(target);
     NopInterceptor nop = new NopInterceptor();
     CountingBeforeAdvice cba = new CountingBeforeAdvice();
     IAdvisor advisor = new DefaultPointcutAdvisor(cba);
     pf.AddAdvice(nop);
     pf.AddAdvisor(advisor);
     ITestObject proxied = (ITestObject)pf.GetProxy();
     proxied.Age = 5;
     Assert.AreEqual(1, cba.GetCalls());
     Assert.AreEqual(1, nop.Count);
     Assert.IsFalse(pf.RemoveAdvisor(null));
     Assert.IsTrue(pf.RemoveAdvisor(advisor));
     Assert.AreEqual(5, proxied.Age);
     Assert.AreEqual(1, cba.GetCalls());
     Assert.AreEqual(2, nop.Count);
     Assert.IsFalse(pf.RemoveAdvisor(new DefaultPointcutAdvisor(null)));
 }
開發者ID:smnbss,項目名稱:spring-net,代碼行數:20,代碼來源:ProxyFactoryTests.cs

示例2: Frozen_RemoveAdvisor

 public void Frozen_RemoveAdvisor()
 {
     ProxyFactory factory = new ProxyFactory();
     factory.IsFrozen = true;
     factory.RemoveAdvisor(null);
 }
開發者ID:smnbss,項目名稱:spring-net,代碼行數:6,代碼來源:ProxyFactoryTests.cs

示例3: RemoveAdvisorByIndex

        public void RemoveAdvisorByIndex()
        {
            TestObject target = new TestObject();
            ProxyFactory pf = new ProxyFactory(target);
            NopInterceptor nop = new NopInterceptor();
            CountingBeforeAdvice cba = new CountingBeforeAdvice();
            IAdvisor advisor = new DefaultPointcutAdvisor(cba);
            pf.AddAdvice(nop);
            pf.AddAdvisor(advisor);
            NopInterceptor nop2 = new NopInterceptor(2); // make instance unique (see SPRNET-847)
            pf.AddAdvice(nop2);
            ITestObject proxied = (ITestObject)pf.GetProxy();
            proxied.Age = 5;
            Assert.AreEqual(1, cba.GetCalls());
            Assert.AreEqual(1, nop.Count);
            Assert.AreEqual(1, nop2.Count);
            // Removes counting before advisor
            pf.RemoveAdvisor(1);
            Assert.AreEqual(5, proxied.Age);
            Assert.AreEqual(1, cba.GetCalls());
            Assert.AreEqual(2, nop.Count);
            Assert.AreEqual(2, nop2.Count);
            // Removes Nop1
            pf.RemoveAdvisor(0);
            Assert.AreEqual(5, proxied.Age);
            Assert.AreEqual(1, cba.GetCalls());
            Assert.AreEqual(2, nop.Count);
            Assert.AreEqual(3, nop2.Count);

            // Check out of bounds
            try
            {
                pf.RemoveAdvisor(-1);
                Assert.Fail("Supposed to throw exception");
            }
            catch (AopConfigException)
            {
                // Ok
            }

            try
            {
                pf.RemoveAdvisor(2);
                Assert.Fail("Supposed to throw exception");
            }
            catch (AopConfigException)
            {
                // Ok
            }

            Assert.AreEqual(5, proxied.Age);
            Assert.AreEqual(4, nop2.Count);
        }
開發者ID:smnbss,項目名稱:spring-net,代碼行數:53,代碼來源:ProxyFactoryTests.cs

示例4: Frozen_RemoveAdvisor

 public void Frozen_RemoveAdvisor()
 {
     ProxyFactory factory = new ProxyFactory();
     factory.IsFrozen = true;
     Assert.Throws<AopConfigException>(() => factory.RemoveAdvisor(null));
 }
開發者ID:spring-projects,項目名稱:spring-net,代碼行數:6,代碼來源:ProxyFactoryTests.cs


注:本文中的Spring.Aop.Framework.ProxyFactory.RemoveAdvisor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。