我有很多實體類,現在在實體類的所有屬性中需要在getters和setter中添加新的功能(調用某個方法)。我想說的是這樣的:在c動態調用方法#
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和依賴注入的問題。 你能幫我嗎?
你已經在做你想做的事情了。只要你有一個refreshContetns方法到它的基類中:-) – 2010-11-29 10:09:48