I'd like to create a method that does the following:
- Takes an arbitrary instance as parameter
- Generates a wrapper instance providing all properties and methods in the same way as the passed instance
- Overrides one method with a different implementation
- Returns that generated instance
This is something quite similar to the proxy objects that ORMs create. They normally do not return the real model classes, but proxy objects that behave the same ways, except for lazy loading, etc.
Is there something suitable out there? (I saw CodeDom, but also saw the opcodes I need to emit for a method implementation...)