Proxy Pattern Demo : Proxy Pattern « Design Patterns « C# / C Sharp






Proxy Pattern Demo

 

using System;

public interface IEmployee {
    string Design();
    string StressTest();
    string Mechanical();
    string Performance();
}

public class ChiefDesignEngineer : IEmployee {

    public string Design() {
        return "Design ";

    }

    public string StressTest() {
        return "Stress Test";
    }

    public string Mechanical() {
        return "mechanical";
    }

    public string Performance() {
        return "performance";
    }

    public ChiefDesignEngineer() { ;}
}


public class ProxyChiefDesignEngineer : IEmployee {
    private ChiefDesignEngineer chief;

    public string Design() {
        return this.chief.Design();
    }

    public string StressTest() {
        return this.chief.StressTest();
    }

    public string Mechanical() {
        return "supplement to mechanical.";
    }
    public string Performance() {
        return "Performance for Chief Design Engineer";
    }
    public ProxyChiefDesignEngineer() {
        this.chief = new ChiefDesignEngineer();
    }

}

public class Client {

    static void Main(string[] args) {
        ProxyChiefDesignEngineer caProxyChief = new ProxyChiefDesignEngineer();

        Console.WriteLine(caProxyChief.StressTest());

        Console.WriteLine(caProxyChief.Performance());

        ProxyChiefDesignEngineer nyProxyChief = new ProxyChiefDesignEngineer();

        Console.WriteLine(nyProxyChief.Mechanical());

    }
}

 








Related examples in the same category

1.Pattern Example: Remote-Proxy