So, I’m trying to explore this all morning, and I’m out of luck. I am trying to find a way to dynamically create a method / delegate / lambda that returns a new instance of a specific class (unknown before execution) that inherits from a specific base class.
I can guarantee the following about an unknown / dynamic class
- It is always inherited from one known class (string)
- It will have at least 2 constructors (one accepts long and one accepts IDataRecord)
I plan to do the following:
- Search for all classes with a specific attribute on them
- Creating a delegate / method / lambda / whatever creating a new instance of the class
- Saving a delegate / something along with some properties in a struct / class
- Paste the structure into a hash table
- If necessary, pull the information from the hash table and call the / all delegate to get a new instance of the class and return it / by adding / etc to the list.
I need help only with C # 2 above !!! I don’t know where to start. I really need some reference materials to get started, or some keywords that need to be thrown at Google.
This is for compact / easy use of ORM for our office here. I understand that this is not so simple, but as soon as you work, you need to make the code incredibly simple.
Please let me know if you need more information! And thanks in advance! :)
source
share