methoddecorator.fody 是否可以使用方法 OnExit 调用实例方法



我正在做一个AOP项目,它有一个类(称之为classA(从另一个类继承(调用是ParentClass(。像波纹管一样的代码

[Interceptor]
class ParentClass
{
protected void Init()
{
...
}
}
class classA : ParentClass
{
}

在创建类A的新实例时,我想通过AOP调用ParentClass的Init((,但我发现这对我来说很难。 请帮忙。

更新。

嗨,伙计们。有一件事你应该知道,我想要一个AOP拦截,而不是来自子类的方法调用。 因为我有太多的对象,我想在.ctoronExit中立即调用。

public class MyParentClass
{
public virtual void SomeMethod()
{
/* do parent class stuff here */
}
}
public class MyChildClass : MyParentClass
{
public override void SomeMethod()
{
/* do child class stuff here */
base.SomeMethod(); // <--- This will call the parent class method
}
}

使用父类的任何方法描述然后使用virtual使用子类的任何方法描述然后使用override

最新更新