I am working on a project that makes extensive use of XML config files, and I would like to take a few things to the next level with generic implementation of shared code.
Problem is, of my five classes, two handle a "description" grid view differently. This grid view shows objects of the appropriate type with various columns.
Also of note: the data is passed via a Data Record, so the GUI does not have direct access to the source object(s).
Here is my current "attempt" to get dynamic data, using a rather silly hack (that did not work)
GetObjectData( MyClass myObject, string[] dataToGet)
{
List<string> dataToReturn = new List<string>();
foreach (string propertyName in dataToGet)
{
try
{
Label tempLabel = new Label();
tempLabel.DataBindings.Add("Text", myObject, propertyName);
dataToReturn.Add(tempLabel.Text);
}
catch { dataToReturn.Add(""); }
}
}
There MUST be a way to do this, but I'm not sure what it would be called, or how to approach the issue.