1 public class Vehicle
2 {
3 public string Name { get; set; }
4 public string Model { get; set; }
5 }
6
7 public interface IGear
8 {
9 void GearUp( Vehicle v );
10 void GearDown( Vehicle v );
11 }
12
13 public class RunVehicle : IGear
14 {
15 public void GearUp( Vehicle v )
16 {
17 Console.WriteLine( "Going one gear up : {0}", v.Name );
18 }
19
20 public void GearDown( Vehicle v )
21 {
22 Console.WriteLine( "Going one gear down : {0}", v.Name );
23 }
24 }
25
26 public class VehicleProxy : IGear
27 {
28 private RunVehicle _runVehicle;
29
30 public VehicleProxy()
31 {
32 _runVehicle = new RunVehicle();
33 }
34
35 public void GearUp( Vehicle v )
36 {
37 _runVehicle.GearUp( v );
38 }
39
40 public void GearDown( Vehicle v )
41 {
42 _runVehicle.GearDown( v );
43 }
44 }
45
46 public class Program
47 {
48 public static void Main()
49 {
50 VehicleProxy proxy = new VehicleProxy();
51
52 proxy.GearUp( new Vehicle { Name = "Vehicle1", Model = "Model1" } );
53 //Output : Going one gear up : Vehicle1
54 proxy.GearDown( new Vehicle { Name = "Vehicle1", Model = "Model1" } );
55 //Output : Going one gear down : Vehicle1
56
57 Console.ReadLine();
58 }
59 }