本文整理汇总了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)));
}
示例2: Frozen_RemoveAdvisor
public void Frozen_RemoveAdvisor()
{
ProxyFactory factory = new ProxyFactory();
factory.IsFrozen = true;
factory.RemoveAdvisor(null);
}
示例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);
}
示例4: Frozen_RemoveAdvisor
public void Frozen_RemoveAdvisor()
{
ProxyFactory factory = new ProxyFactory();
factory.IsFrozen = true;
Assert.Throws<AopConfigException>(() => factory.RemoveAdvisor(null));
}