-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path外观模式.cs
56 lines (53 loc) · 1.35 KB
/
外观模式.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using Xunit;
namespace DesignMode
{
/// <summary>
/// 为子系统的一组接口提供一个一致的页面
/// 此模式定义了一个高层接口,这个接口使得这一子系统更加容易使用
/// </summary>
public class 外观模式
{
[Fact]
public void Test()
{
Facade facade = new Facade();
facade.MethodA();
}
class Facade
{
SubSystemOne one;
SubSystemTwo two;
public Facade()
{
one = new SubSystemOne();
two = new SubSystemTwo();
}
public void MethodA()
{
one.MethodOne();
two.MethodTwo();
System.Console.WriteLine("方法组A");
}
public void MethodB()
{
two.MethodTwo();
one.MethodOne();
System.Console.WriteLine("方法组B");
}
}
class SubSystemOne
{
public void MethodOne()
{
System.Console.WriteLine("子系统方法一");
}
}
class SubSystemTwo
{
public void MethodTwo()
{
System.Console.WriteLine("子系统方法二");
}
}
}
}