How to access to property of property in object instance using string ? I would like automate changes i will made in form for example responding to object below:
class myObject{
Vector3 position;
public myObject(){
this.position = new Vector3( 1d,2d,3d);
}
};
Form have eg three numericUpDown called respectively position_X,position_Y,position_Z;
Instead having three callbacks for events as:
private void positionX_ValueChanged(object sender, EventArgs e)
{
// this.model return myObject
this.model().position.X = (double) ((NumericUpDown)sender).Value;
}
I would have one callback which can automatically set particular attribute in model from control name/tag
Below is javascript which describe purpose i want :)
position_Changed( sender ){
var prop = sender.Tag.split('_'); ; // sender.Tag = 'position_X';
this.model[ prop[0] ] [ prop[1] ] = sender.Value;
}