public static void Main()
        {
            Console.WriteLine("Authetication Proxy");
            ISubject subject = new Proxy();

            Console.WriteLine(subject.Request());                                       // Actually create the subject
            subject = new ProtectionProxy();
            Console.WriteLine((subject as ProtectionProxy).Authenticate("LOLLIPOPS!")); // If the password is correct then the subject is requested
            Console.WriteLine(subject.Request());
        }
        static void Main(string[] args)
        {
            ISubject subject = new Proxy();

            System.Console.WriteLine(subject.Request());

            subject = new ProtectionProxy();

            System.Console.WriteLine((subject as ProtectionProxy).Authenticate("test"));

            System.Console.WriteLine(subject.Request());
        }
예제 #3
0
        /*
         * Intent
         * The intent of this pattern is to provide a �Placeholder� for an object to control references to it.
         */
        static void Main(string[] args)
        {
            Console.WriteLine("Proxy Pattern\n");

            ISubject proxy = new Proxy();

            Console.WriteLine(proxy.Request());
            Console.WriteLine(proxy.Request());

            var protectionProxy = new ProtectionProxy();

            Console.WriteLine(protectionProxy.Request());

            Console.WriteLine((proxy as ProtectionProxy).Authenticate("Secret"));
            Console.WriteLine((proxy as ProtectionProxy).Authenticate("Abracadabra"));
            Console.WriteLine(proxy.Request());
        }