C# methoddecorator.fody是否可以使用方法OnExit调用实例方法
我正在处理一个AOP项目,其中有一个类(称为classA)继承自另一个类(称为ParentClass)。暗号C# methoddecorator.fody是否可以使用方法OnExit调用实例方法,c#,aop,C#,Aop,我正在处理一个AOP项目,其中有一个类(称为classA)继承自另一个类(称为ParentClass)。暗号 [Interceptor] class ParentClass { protected void Init() { ... } } 创建classA的新实例时,我希望AOP调用ParentClass的Init(),但我发现这对我来说很难。 请帮忙 更新。 嗨,伙计们。有一件事你们应该知道,我想要一个AOP截取,而不是来自子类的方法调用。因为我有太多
[Interceptor]
class ParentClass
{
protected void Init()
{
...
}
}
创建classA的新实例时,我希望AOP调用ParentClass的Init(),但我发现这对我来说很难。
请帮忙
更新。
嗨,伙计们。有一件事你们应该知道,我想要一个AOP截取,而不是来自子类的方法调用。因为我有太多的对象,我希望在.ctor公共类MyParentClass的onExit中立即调用
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
}
}
{
公共虚拟方法()
{
/*在这里做家长课的事情*/
}
}
公共类MyChildClass:MyParentClass
{
公共重写无效方法()
{
/*在这里做儿童课的事情*/
base.SomeMethod();//您使用的是哪种AOP框架?有用我喜欢这段代码只参考代码链接:-@YuriyFaktorovich,AOP框架是MethodDecorator.fody这是一个直接的父方法调用,而不是AOP
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
}
}