Design Pattern Examples
Overview of object-oriented design patterns
Proxy_Exercise.cs
Go to the documentation of this file.
1
5
6using System;
7
9{
27 internal class Proxy_Exercise
28 {
32 // ! [Using Proxy in C#]
33 public void Run()
34 {
35 Console.WriteLine();
36 Console.WriteLine("Proxy Exercise");
37
38 Console.WriteLine(" Getting proxy object...");
40
41 Console.WriteLine(" Calling Dowork() on proxy...");
42 string output = proxyObject.DoWork("Initial call");
43 Console.WriteLine(" Output from proxy = \"{0}\"", output);
44
45 Console.WriteLine(" Calling Dowork() on proxy...");
46 output = proxyObject.DoWork("Second call");
47 Console.WriteLine(" Output from proxy = \"{0}\"", output);
48
49 Console.WriteLine(" Calling Dowork() on proxy...");
50 output = proxyObject.DoWork("Third call");
51 Console.WriteLine(" Output from proxy = \"{0}\"", output);
52 Console.WriteLine(" Done.");
53 }
54 // ! [Using Proxy in C#]
55 }
56}
For the purposes of this example, this class encapsulates the real class and proxy class to hide them...
Definition: Proxy_Class.cs:40
static IWorkByProxy CreateProxy()
Retrieve a new instance of the proxy class.
Definition: Proxy_Class.cs:131
Example of using the Proxy Pattern in C#.
void Run()
Executes the example for the Proxy Pattern in C#.
Represents what can be done on the proxy object. This same interface is implemented on the real objec...
Definition: Proxy_Class.cs:19
string DoWork(string someArgument)
Does some work on the given argument and returns a new string.
The namespace containing all Design Pattern Examples implemented in C#.