Ok That way, I have code that maps specific winForm controls to certain object properties to do certain things for controls when certain things happen to data. All is well and good, works great. Not a problem. The problem is that to add elements to the mapping, I call a function that looks like this:
this.AddMapping(this.myControl,myObject,"myObjectPropertyName");
The problem I am facing is that at compile time it is very difficult to determine the difference between the line above and below:
this.AddMapping(this.myControl,myObject,"myObjectPropretyName");
Since the last parameter is a string, there is no compilation time check or anything similar that would ensure that the string itself actually matches the valid property name for this object. In addition, things like Refactor and "Find All References" skip this link, which leads to fun when the property name changes. So I'm wondering if there is any way to change the function, so what I pass in is still a string representing the property name in some way, but with checking the compile time of the actual value. Someone said that I can do this with expression trees, but I read them and don't seem to see the connection. I would like to do something like:
this.AddMapping(this.myControl,myObject,myObject.myObjectPropertyName);
or even
this.AddMapping(this.myControl,myObject.myObjectPropertyName);
will be sweet!
Any ideas?
reflection c # mapping compile-time intellisense
GWLlosa Apr 27 '09 at 20:43 2009-04-27 20:43
source share