I have a dll file, which include various derived class which inherits from base class and this base class have a virtual method named "Run" and in derived classes there is no overridden "Run" method. Now, the behaivior of method Run change in specific case and I want to apply for all derived class so if I want change to that behaivior, normally I have to create various custom derived class class which inherit from derived class and override "Run" method. It is burdensome if the number of derived class is many and it cause the duplicate source. Note I dont have permit to modify any existing in that dll file.
dll file:
public abstract class Animal
{
public virtual void Run()
{
Console.WriteLine("Hello 1");
}
}
public class Dogs : Animal
{
//do other thing.
}
public class Cat : Animal
{
//do other thing.
}
client side nomally:
public class CusTomDogs : Dogs
{
public override void Run()
{
Console.WriteLine("Hello 2");
}
}
public class CusTomCat : Cat
{
public override void Run()
{
Console.WriteLine("Hello 2");
}
}
Is there possible way to change behavior "base.Run()" method without create custom each derrived class?