Using system; using system. collections. generic; using system. LINQ; using system. text; using system. threading. tasks; namespace designmodel {public class Proxy: iaction {zqz ZZZ = NULL; Public proxy (zqz mm) {ZZZ = mm;} public void sendflower () {zzz. sendflower ();} public void sendcake () {zzz. sendcake () ;}} public interface iaction {void sendflower (); void sendcake ();} public class zqz: iaction {Public String myname {set; get ;} public void sendflower () {console. writeline (myname + "sending flowers");} public void sendcake () {console. writeline (myname + "Send cake ");}}}
Client call:
1 zqz ZZZ = new zqz (); 2 zzz. myname = "Zhu Jianjun"; 3 proxy P = new proxy (zzz); 4 p. sendflower (); 5 p. sendcake ();
View code
Proxy mode classification:
1. remote proxy, which provides a local representation of an object in different address spaces, so that the fact that an object exists in different address spaces can be hidden.
For example, WebService
2. Virtual Proxy: Creates objects with high overhead as needed. It stores real objects that take a long time for instantiation.
The browser uses the proxy mode to optimize the download page.
3. Security Proxy
Used to control the access permissions of real objects.
4. Smart Guidance
The proxy handles other things when calling a real object.