5. Big talk design mode-proxy Mode

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.