The proxy pattern is a structural design pattern providing objects that act as substitutes for real service objects used by clients. Proxies receive client requests, perform the required work, and then pass the request to service objects. Proxy objects are interchangeable with services as they share the same interfaces:
An example of when you would want to use the proxy pattern is when you have a class that you do not want to change, but where you do need additional behaviors to be added. Proxies delegate work to other objects. Unless a proxy is a derivative of a service, proxy methods should finally refer to a Service object.
We will look at a very simple implementation of the proxy pattern. Add a folder to the root of your Chapter 11 project called ProxyPattern. Add an interface called IService with a single method to handle a request:
public interface IService {
void Request();
}
TheRequest()method...