我有很多实体类,现在在实体类的所有属性中都需要在 getter 和 setter 中添加新功能(调用某些方法)。我想说的看起来像这样:
public class PersistentClass : BaseClass {
private string attr1;
[Persistent]
public string Attr1
{
get
{
//need to call here base class method
//refreshContents();
return attr1;
}
set
{
//need to call here base class method
//refreshContents();
attr1 = value;
}
}
private SomeObject attr2;
[Persistent]
public SomeObject Attr2
{
get
{
//need to call here base class method
//refreshContents();
return attr2;
}
set
{
//need to call here base class method
//refreshContents();
attr2 = value;
}
}
private List<SomeOtherObhect> details;
[Persistent]
pubic List<SomeOtherObject> Details
{
get
{
//need to call here base class method
//refreshContents("details");
return details;
}
set
{
//need to call here base class method
//refreshContents("details");
details = value;
}
}
}
对于不同类型的字段,我需要调用不同的方法,例如refreshContents()
和refreshContetns("fieldName")
。我正在寻找解决 IoC 和依赖注入的问题。请问你能帮帮我吗?