samedi 19 mai 2018

external changing implementation of class

Is there a way to change implementation of given class from outside? For example, I have the following implementation:

 public partial class Test
{
    public Interface1 Field = new Class1();
}
public interface Interface1
{
    //implementation    
}
public class Class1 : Interface1
{
    //implementation
}

I would like to define another class:

public class Class2 : Interface1
{
    //implementation
}

and change Test.Field to be object of Class2 class. I cannot modify implementation of Test class. I can only add another file with its partial implementation. I cannot also use any dependency injection libraries.





Aucun commentaire:

Enregistrer un commentaire