本文整理匯總了C#中System.Proxy.OverloadedGo方法的典型用法代碼示例。如果您正苦於以下問題:C# Proxy.OverloadedGo方法的具體用法?C# Proxy.OverloadedGo怎麽用?C# Proxy.OverloadedGo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Proxy
的用法示例。
在下文中一共展示了Proxy.OverloadedGo方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Can_Intercept_Multiple_Methods_Using_A_Filter
public void Can_Intercept_Multiple_Methods_Using_A_Filter()
{
var ack = 0;
var foo = new Foo();
var proxy = new Proxy<IFoo>()
.Target(foo)
.InterceptWhere(mi => mi.Name.EndsWith("Go"))
//.InterceptWhere(mi => mi.IsGenericMethod )
.OnBefore(mi => ack++)
.Save();
// intercepted
proxy.Go();
proxy.GenericGo<int>(-1);
proxy.OverloadedGo(-1);
proxy.OverloadedGo(string.Empty);
// not intercepted
proxy.Name = string.Empty;
proxy.Return();
Assert.Equal(4, ack);
}
示例2: Can_Intercept_Overloaded_Methods
public void Can_Intercept_Overloaded_Methods()
{
var ack = false;
var foo = new Foo();
var proxy = new Proxy<IFoo>()
.Target(foo)
.InterceptMethod(f => f.OverloadedGo(It.Any<string>()))
.OnBefore(() => ack = true)
.Save();
proxy.OverloadedGo(-1); // not intercepted
Assert.False(ack);
proxy.OverloadedGo(string.Empty); // intercepted
Assert.True(ack);
}
示例3: Can_Intercept_Many_Methods_With_One_Advice
public void Can_Intercept_Many_Methods_With_One_Advice()
{
var ack = 0;
var foo = new Foo();
var proxy = new Proxy<IFoo>()
.Target(foo)
.InterceptMethods(
f => f.Return(),
f => f.GenericGo<int>(It.Any<int>()),
f => f.Go())
.OnBefore(mi => ack++)
.Save();
// intercepted
proxy.Go();
proxy.Return();
proxy.GenericGo<int>(-1);
// not intercepted
proxy.Name = string.Empty;
proxy.OverloadedGo(-1);
proxy.OverloadedGo(string.Empty);
Assert.Equal(3, ack);
}