本文整理汇总了C#中System.Proxy.GenericGo方法的典型用法代码示例。如果您正苦于以下问题:C# Proxy.GenericGo方法的具体用法?C# Proxy.GenericGo怎么用?C# Proxy.GenericGo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Proxy
的用法示例。
在下文中一共展示了Proxy.GenericGo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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_Generic_Methods
public void Can_Intercept_Generic_Methods()
{
var ack = 0;
var foo = new Foo();
var proxy = new Proxy<IFoo>()
.Target(foo)
.InterceptMethod(f => f.GenericGo<int>(It.Any<int>()))
.OnBefore(() => { Assert.False(foo.WasExecuted); ack++; })
.InterceptMethod(f => f.GenericGo<string>(It.Any<string>()))
.OnAfter(() => { ack++; })
.Save();
proxy.GenericGo<int>(1); // intercepted
proxy.GenericGo<string>(string.Empty); // intercepted
proxy.GenericGo<double>(2d); // not intercepted
proxy.GenericGo<object>(It.Any<object>()); // not intercepted
Assert.True(foo.WasExecuted);
Assert.Equal(2, 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);
}
示例4: Can_Intercept_All_Methods_Getters_And_Setters
public void Can_Intercept_All_Methods_Getters_And_Setters()
{
var ack = 0;
var foo = new Foo();
var proxy = new Proxy<IFoo>()
.Target(foo)
.InterceptAll()
.OnFinally(() => { ack++; })
.Save();
// intercepts all gettrers, setters and methods...
proxy.Go();
var name = proxy.Name;
var description = proxy.Description;
proxy.Name = string.Empty;
var result = proxy.GenericGo<int>(-1);
Assert.Equal(5, ack);
}