【发布时间】:2012-06-11 22:21:40
【问题描述】:
我希望能够使用PostSharp 在我截获的类上调用不同的方法。
假设我的PostSharp 方面有以下方法:
public override void OnInvoke(MethodInterceptionArgs args)
{
if (!m_featureToggle.FeatureEnabled)
{
base.OnInvoke(args);
}
else
{
var instance = args.Instance;
instance.CallDifferentMethod(); //this is made up syntax
}
}
CallDifferentMethod() 是类中另一个被拦截的方法。我可以做一些反射魔法来获得我想要被调用的名称,但我不知道如何在类的 this 实例上调用该方法。我不想启动类的新实例
有什么建议吗?
【问题讨论】: