Replacing method/logic in class and runtime.
-
Is there a way to replace a method in the class at runtime? Basically i want a method in a class to use new logic at runtime. I am trying to write a unit test and want to compare results between old and new logic. therefore, planning to replace a method/logic, or somehow make runtime to redirect calls to my new logic. Thanks.
-
Is there a way to replace a method in the class at runtime? Basically i want a method in a class to use new logic at runtime. I am trying to write a unit test and want to compare results between old and new logic. therefore, planning to replace a method/logic, or somehow make runtime to redirect calls to my new logic. Thanks.
Err,
if
statement?bool cheeseIsGood = true;
...
if(cheeseIsGood)
{
MethodOne();
}
else
{
MethodTwo();
}Or something similar. Just change the bool to false when you want to check the other code, using a button or any other means.
My current favourite word is: Delicious!
-SK Genius
-
Is there a way to replace a method in the class at runtime? Basically i want a method in a class to use new logic at runtime. I am trying to write a unit test and want to compare results between old and new logic. therefore, planning to replace a method/logic, or somehow make runtime to redirect calls to my new logic. Thanks.
Giorgi Dalakishvili #region signature My Articles Asynchronous Registry Notification Using Strongly-typed WMI Classes in .NET [^] My blog #endregion
-
Err,
if
statement?bool cheeseIsGood = true;
...
if(cheeseIsGood)
{
MethodOne();
}
else
{
MethodTwo();
}Or something similar. Just change the bool to false when you want to check the other code, using a button or any other means.
My current favourite word is: Delicious!
-SK Genius
It seems i didn't explain my problem properly. Eg. Assembly a.dll has private method1() I am using a.dll in my unit test. Instead of executing logic of a.dll method1(), i want somehow redirect call to my method1(), which i created in unit test project. thanks.
-
It seems i didn't explain my problem properly. Eg. Assembly a.dll has private method1() I am using a.dll in my unit test. Instead of executing logic of a.dll method1(), i want somehow redirect call to my method1(), which i created in unit test project. thanks.
So you have a dll with a private method, and this method is called from within the dll? But you want to redirect all calls to the method to one you created outside of the dll? Meaning that all calls made from with the dll to the usual function would actually be calling a new method that is outside of the dll. Or are you just calling the method inside the dll from outside of it?
My current favourite word is: Delicious!
-SK Genius