static void Main(string[] args) { var image1 = new ProxyImage("1.txt"); image1.Display(); Console.ReadKey(); }
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) { IImage image = new ProxyImage("test_10mb.jpg"); //图像将从磁盘加载 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 Main(string[] args) { IImage image = new ProxyImage("HiRes_Image"); for (int i = 0; i < 10; i++) { image.Display(); } }
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) { Image image1 = new ProxyImage("HiRes_10MB_Photo1;"); Image image2 = new ProxyImage("HiRes_10MB_Photo2;"); image1.DisplayImage(); image2.DisplayImage(); Console.ReadKey(); }
static void Main(string[] args) { IImage image1 = new ProxyImage("HiRes_10MB_Photo1"); IImage image2 = new ProxyImage("HiRes_10MB_Photo2"); image1.DisplayImage(); image1.DisplayImage(); image2.DisplayImage(); image2.DisplayImage(); Console.ReadKey(); }
/* * - INTENÇÃO: fornece um substituto (surrogate) ou marcador da localização de outro objeto * para controlar o acesso ao mesmo. * - Um objeto representando um outro objeto. */ static void Main(string[] args) { Image image1 = new ProxyImage("HiRes_10MB_Photo1"); Image image2 = new ProxyImage("HiRes_10MB_Photo2"); image1.displayImage(); image2.displayImage(); image1.displayImage(); }
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) { Console.WriteLine("Loading 3 hi-res (proxy) images"); ProxyImage image1 = new ProxyImage("jotain"); ProxyImage image2 = new ProxyImage("jotain"); ProxyImage image3 = new ProxyImage("jotain"); Console.WriteLine("Calling show to image1"); image1.ShowImage(); Console.ReadLine(); }
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(); }
static void Main(string[] args) { //======================================= ProxyImage proxyImage = new ProxyImage("http://abc.com/a.png"); Console.WriteLine("Call real service 1st: "); proxyImage.ShowImage(); Console.WriteLine("Call real service 2nd: "); proxyImage.ShowImage(); //======================================= /*UserProxy user1 = new UserProxy("user1", "admin"); * Console.WriteLine(user1.ReadFile()); * * UserProxy user2 = new UserProxy("user2", "member"); * Console.WriteLine(user2.ReadFile());*/ }
static void Main(string[] args) { IImage Image1 = new ProxyImage("Tiger Image"); Console.WriteLine("Image1 calling DisplayImage first time :"); Image1.DisplayImage(); // loading necessary Console.WriteLine("Image1 calling DisplayImage second time :"); Image1.DisplayImage(); // loading unnecessary Console.WriteLine("Image1 calling DisplayImage third time :"); Image1.DisplayImage(); // loading unnecessary Console.WriteLine(); IImage Image2 = new ProxyImage("Lion Image"); Console.WriteLine("Image2 calling DisplayImage first time :"); Image2.DisplayImage(); // loading necessary Console.WriteLine("Image2 calling DisplayImage second time :"); Image2.DisplayImage(); // loading unnecessary Console.ReadKey(); }
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(); }