c# - Implementing Binding Paths -
trying implement field binding system , have following method:
public void setvalue<tfield>(expression<func<tfield>> field, object value) { ((field.body memberexpression).member fieldinfo).setvalue(this, value); // check bindings etc. }
that used this:
myobj.setvalue(() => myobj.somestringfield, "somestring");
it works intended, value set , can other stuff want checking bindings etc.
now i'm trying implement support of binding paths, i.e. allow like:
myobj.setvalue(() => myobj.names[1].firstname, "john");
i got fieldinfo of firstname need (at least) reference object myobj.names[1] expression. ideas on how this?
a general approach create expression assigns value expression:
public static void setvalue<tfield>(expression<func<tfield>> field, tfield value) { var expression = expression.lambda<action>( expression.assign(field.body, expression.constant(value))); expression.compile()(); }
Comments
Post a Comment