I have a scenario where I use castle dynamic proxy to be able to intercept and log message calls to any given class(let's call it the target class). I do this by wrapping the target-class in a class that creates a proxy of the class with a interceptor that logs all method calls to the target-class. This works fine. The only issue is that for this to work all public methods on the target-class needs to be virtual which for more reasons is not desirable.
I could create a solution where i validate that all methods are virtual when I create the proxy and throws a exception if this is not the case, but I would rather if it was possible to change the methods to be virtual using reflection (or something else) before generating the proxy. This way I will be able to use the on all classes without paying attention to if it has virtual methods or not.
What am I missing here, can I archive this somehow?
Aucun commentaire:
Enregistrer un commentaire