I am creating a library that pulls HTML tables from the web and converts them to objects. I have a ColumnConfigurator object that pre-configures how a specific table is laid out:
config.Column().Text().MapTo(/*Class.TextPropertyName*/); //What I want to be able to do
config.Column().Date().MapTo(/*Class.DatePropertyName*/);
The above code is the general idea of what I want to be able to do in the configuration (note that the first function creates a new column and returns it, and the subsequent methods set the object's configuration), and then when the table is being mapped to I'd like to retrieve the parameter passed into MapTo and have it automatically resolve to the correct property of a given object.
Here's what's confusing me the most: I want to make the main table object generic (ParsingTable<T>
) so that theoretically any object can be mapped to. This means that none of the properties are available ahead of time. I'd like to pass the T.Property
into the method so it knows how to automap. Is there a way to do this? I've read a small bit about reflection but heard it's bad for performance.