[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Latest commit

 

History

History

Proxy

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 


In proxy pattern, a class represents functionality of another class. This type of design pattern comes under structural pattern.

In proxy pattern, we create object having original object to interface its functionality to outer world.

Implementation

interface IHuman { void Request(); }


class Operator : IHuman
{
    public void Request()
    {
        Console.WriteLine("Operator");
    }
}

//Proxy
class Surrogate : IHuman
{
    IHuman @operator;
    public Surrogate(IHuman @operator)
    {
        this.@operator = @operator;
    }
    public void Request()
    {
        @operator.Request();
    }
}


//Program

class Program
{
    static void Main(string[] args)
    {
        IHuman Bruce = new Operator();
        Surrogate surrogate = new Surrogate(Bruce);
        surrogate.Request();
    }
}

Full for implementation here