reflection - c# PropertyInfo extract inner expression -


i have use reflection cycle through properties of reflected object, , collect propertyinfo objects.

some of properties of type expression<func<type1,string>>, , have extract underlying expression property info.

i tried mypropertyinfo.getvalue(parparameter) lambdaexpression not seem work.

can give me pointers?

your usage of mypropertyinfo.getvalue(parparameter) lambdaexpression suspect, because parameters , expressions 2 different things. seems you're mixing variables after reflection. here's example may clarify things:

class type1 { public string name { get; set; } } class data { public expression<func<type1, string>> ex { get; set; } } class program {     static void main(string[] args)     {         var d = new data { ex = t => t.name };         var pi = d.gettype().getproperties().single();         var ex = pi.getvalue(d) lambdaexpression;         console.writeline(pi.getvalue(d).gettype());         console.writeline(ex);         console.writeline(ex.parameters.single());     } } 

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -