Proxcy代理模式
1 using System;
2
3 interface IEmployee
4 {
5
6 public void GetSalary();
7 public void Report();
8 public void ApplyVacation();
9 }
10
11
12 //运行在internet远端的一台机器上
13 class Employee : IEmployee
14 {
15
16 void IEmployee.GetSalary()
17 {
18 //
19 }
20
21 void IEmployee.Report()
22 {
23 //
24 }
25
26 void IEmployee.ApplyVacation()
27 {
28 //
29 }
30
31 }
32
33
34 //运行在本地的WindowsForms
35 class EmployeeProxcy : IEmployee
36 {
37 public EmployeeProxcy()
38 {
39 //对对象创建的一种SOAP封装
40 }
41
42
43
44 public void GetSalary()
45 {
46 //对对象创建访问的一种SOAP封装
47
48 //发送SOAP数据
49
50 //如果有返回值接受返回值SOAP,解包,返回原生的(RAW)的C#数据
51
52 }
53
54 public void Report()
55 {
56 }
57
58 public void ApplyVacation()
59 {
60 }
61
62 }
63
64 class HrSystem
65 {
66 public void Process()
67 {
68 IEmployee employee = new EmployeeProxcy();
69
70 employee.Report();
71 //.
72
73 employee.ApplyVacation();
74 //
75 }
76 }
2
3 interface IEmployee
4 {
5
6 public void GetSalary();
7 public void Report();
8 public void ApplyVacation();
9 }
10
11
12 //运行在internet远端的一台机器上
13 class Employee : IEmployee
14 {
15
16 void IEmployee.GetSalary()
17 {
18 //
19 }
20
21 void IEmployee.Report()
22 {
23 //
24 }
25
26 void IEmployee.ApplyVacation()
27 {
28 //
29 }
30
31 }
32
33
34 //运行在本地的WindowsForms
35 class EmployeeProxcy : IEmployee
36 {
37 public EmployeeProxcy()
38 {
39 //对对象创建的一种SOAP封装
40 }
41
42
43
44 public void GetSalary()
45 {
46 //对对象创建访问的一种SOAP封装
47
48 //发送SOAP数据
49
50 //如果有返回值接受返回值SOAP,解包,返回原生的(RAW)的C#数据
51
52 }
53
54 public void Report()
55 {
56 }
57
58 public void ApplyVacation()
59 {
60 }
61
62 }
63
64 class HrSystem
65 {
66 public void Process()
67 {
68 IEmployee employee = new EmployeeProxcy();
69
70 employee.Report();
71 //.
72
73 employee.ApplyVacation();
74 //
75 }
76 }