static void Main(string[] args) { IImage image = new ProxyImage("Some image"); image.Display();//download is commited only once image.Display(); Console.ReadKey(); }
static void Main(string[] args) { Image img = new ProxyImage("hakan.jpg"); img.Display(); //Not Loaded img.Display(); Console.ReadLine(); }
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(); }
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(); }
static void Main(string[] args) { var image1 = new ProxyImage("1.txt"); image1.Display(); Console.ReadKey(); }
static void Main(string[] args) { IImage image = new ProxyImage("test_10mb.jpg"); //图像将从磁盘加载 image.Display(); Console.ReadKey(); }
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(); }
public static void Main(string[] args) { IImage image = new ProxyImage("HiRes_Image"); for (int i = 0; i < 10; i++) { image.Display(); } }
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(); }