lundi 28 mars 2016

Expose Methods in Properties as Single Class

I needed to break up a WCF service contract that had a massive interface and clientbase class into smaller classes. All of the smaller classes are similar but have different operation contracts. I want to be able to expose the operation contract methods in all the new sub-classes as a single class for backwards compatibility. Ideally it would look something like this:

public class MainClient {

    public MainClient() {
        Sub1 = new Sub1Client();
        Sub2 = new Sub2Client();
    }

    public static Sub1Client Sub1;
    public static Sub2Client Sub2;
}

I would then want to be able to call methods from Sub1 and Sub2 as if those methods were defined in MainClient. So instead of calling (new MainClient()).Sub1.Method1() I would call (new MainClient()).Method1() where Method1 still exists in the Sub1Client class.

Is this possible?

Aucun commentaire:

Enregistrer un commentaire