c# - MemberExpression actual values -
class sometype { public string value { get; set; } }
lets have create function call below notation:
var someinstance = new sometype(); dosomethingonexpression(()=>someinstance.value);
where method should that
void dosomethingonexpression<t>(expression<func<t>> exp) { memberexpression mexp = (memberexpression)exp.body; sometype sometypeinsance = ... //from mexp (1) string sometypevaluestring = ... //from mexp (2) string someintancemembername = (memberexpression)exp.body).member.name; assert.equals(sometypeinstance.value, sometypevaluestring) }
any idea how accomplish this?
so basically, question is: can extract member value memberexpression (2) , if can extract instance of type owner of instance
Comments
Post a Comment