当前位置: 首页>>代码示例>>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;未经允许,请勿转载。