示例#1
0
        static void Main()
        {
            Console.WriteLine("Proxy pattern\n");
            ISubject subject = new Proxy();

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

            var protectionProxy = new ProtectionProxy();

            Console.WriteLine(protectionProxy.Request());
            Console.WriteLine(protectionProxy.Authenticate("Secret"));
            Console.WriteLine(protectionProxy.Authenticate("Abracadabra"));
            Console.WriteLine(protectionProxy.Request());
        }
示例#2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Proxy Pattern\n");
            ISubject subject = new ProxyClass();

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

            ProtectionProxy subject2 = new ProtectionProxy();

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

            Console.ReadLine();
        }