Пример #1
0
        static void Main(string[] args)
        {
            IImage image = new ProxyImage("Some image");

            image.Display();//download is commited only once
            image.Display();
            Console.ReadKey();
        }
Пример #2
0
        static void Main(string[] args)
        {
            Image img = new ProxyImage("hakan.jpg");
            img.Display();

            //Not Loaded
            img.Display();
            Console.ReadLine();
        }
Пример #3
0
        public static void Demo()
        {
            IImage i = new ProxyImage("test.jpg");

            //image will  be loaded from disk
            i.Display();
            //image will not be loaded from disk
            i.Display();
            Console.ReadLine();
        }
Пример #4
0
        static void Main(string[] args)
        {
            IImage image = new ProxyImage("UltraHD_pic.jpg");

            // Use factory instead of direct instantiations. Client typicaly don't
            // knows or cares that it's using proxy instead of the concrete subject

            // Image will be loaded to memory and shown .
            image.Display();

            // Image is already loaded! Show image directly from memory.
            image.Display();
        }
Пример #5
0
        static void Main(string[] args)
        {
            var image1 = new ProxyImage("1.txt");

            image1.Display();
            Console.ReadKey();
        }
Пример #6
0
        static void Main(string[] args)
        {
            IImage image = new ProxyImage("test_10mb.jpg");

            //图像将从磁盘加载
            image.Display();

            Console.ReadKey();
        }
Пример #7
0
        public static void Main(string[] args)
        {
            IImage image1 = new ProxyImage("HiRes_10MB_Photo1");
            IImage image2 = new ProxyImage("HiRes_20MB_Photo2");

            // выполняется загрузка
            image1.Display();
            // загрузка не выполняется
            image1.Display();
            // выполняется загрузка
            image2.Display();
            // загрузка не выполняется
            image2.Display();
            // загрузка не выполняется
            image1.Display();

            Console.ReadLine();
        }
Пример #8
0
        public static void Main(string[] args)
        {
            IImage image = new ProxyImage("HiRes_Image");

            for (int i = 0; i < 10; i++)
            {
                image.Display();
            }
        }
Пример #9
0
        static void Main(string[] args)
        {
            // canonical
            var subject = new RealSubject();

            subject.Request();

            var proxy = new Proxy.Canonical.Proxy();

            proxy.Request();

            // live
            Console.WriteLine();

            var image = new ProxyImage("C://temp.jpq");

            // will be loaded lazyly
            image.Display();

            // wont be loaded 2nd time
            image.Display();
        }