(C #) proxy mode

Source: Internet
Author: User

1. Proxy mode

Provides a proxy for other objects to control access to this object.

    1. Remote Proxy: Provides a report representative for an object in a different address space. This can hide the fact that an object is in a different address space.
    2. Virtual proxy: Creates expensive objects on demand. It's the real object that takes a long time to store the instantiation.
    3. Security Agent: The permission used to control the access of real objects.
    4. Smart proxy: The agent handles other things when a real object is called.

2. Example

namespaceProxy Mode {classProgram {Static voidMain (string[] args) {girlmm mm=Newgirlmm (); Mm. Name="Summer Wallpaper"; Proxy proxy=NewProxy (mm); Proxy.            Givedolls (); Proxy.            Giveflowers (); Proxy.            Givechocolate ();        Console.ReadLine (); }    }    /// <summary>    ///operation interface performed by the proxy object/// </summary>    InterfaceIgivegift {voidGivedolls (); voidgiveflowers (); voidgivechocolate (); }    /// <summary>    ///class that the agent wants the agent to perform operations on/// </summary>    classGIRLMM {Private stringname;  Public stringName {Get{returnname;} Set{name =value;} }    }    /// <summary>    ///represented by/// </summary>    classPursuit:igivegift {girlmm mm;  PublicPursuit (girlmm mm) { This. mm =mm; }         Public voidGivedolls () {Console.WriteLine (mm). Name+"give you a doll ."); }         Public voidGiveflowers () {Console.WriteLine (mm). Name+"Send you flowers"); }         Public voidGivechocolate () {Console.WriteLine (mm). Name+"give you the chocolates ."); }    }    classproxy:igivegift {Pursuit gg;  PublicProxy (girlmm mm) {GG=NewPursuit (mm); }         Public voidgivedolls () {Gg.        Givedolls (); }         Public voidgiveflowers () {Gg.        Giveflowers (); }         Public voidgivechocolate () {Gg.        Givechocolate (); }    }}

(C #) proxy mode

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.