本文整理匯總了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));
}