I have performance problems when using reflection in the loops. The thing is I am using it to repeatedly access objects at the end of the long dependency chains. For example, in a situation like that
class FirstObject
{
public SecondObject sO;
}
class SecondObject
{
public ThirdObject tO;
}
class ThirdObject
{
public FourthObject fO;
}
class FourthObject
{
public object neededValue;
}
Since I am interested only in a value contained by the last object, I need to repeatedly travel through the whole chain with GetProperty().GetValue()
FirstObject -> SecondObject -> ThirdObject -> FourthObject [neededValue]
Is there any way, perhaps some API, which could be used to shorten chains or to just save the whole path to neededValue
in this situations?
Aucun commentaire:
Enregistrer un commentaire