How can i change the implementation of a method at runtime from return false;
to return true;
? I don't have control over the methods implementation as it comes with a third-party library. Any workaround is appreciated. Again: I do not control neither the method itself nor it's callers.
views:
132answers:
5
A:
A little more info would help. Can you wrap the library and have others call your wrapper? This might be a great TDD avenue too. Are there interfaces involved you can implement yourself? Again, DI could allow you to swap out implementations.
n8wrl
2009-07-14 11:08:57
it is a static method.
usr
2009-07-14 11:41:19
A:
You can intercept the callers of that method and return true instead calling it. Maybe you can post more details.
A:
Please provide more information about your problem. If you only want to switch the boolean result a simple bool result = !MyMethod();
will be enought ;)
Alexander
2009-07-14 11:37:32
He can't do either - it's a static method (see first comment to first answer) and he doesn't control the call sites
SLaks
2009-07-14 15:25:44