📄 facade.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
namespace DesignDll
{
/************************************************************************
* 外观模式;(Facade Method) 为子系统中的一组接口提供一个一致的界面,此模式定
* 义了一个高层的接口,这个接口使得这一子系统更加容易使用
* **********************************************************************/
/// <summary>
/// 子系统A
/// </summary>
public class SubSystemA
{
public string MethodA()
{
return "调用SubSystemA的方法";
}
}
/// <summary>
/// 子系统B
/// </summary>
public class SubSystemB
{
public string MethodB()
{
return "调用SubSystemB的方法";
}
}
/// <summary>
/// 子系统C
/// </summary>
public class SubSystemC
{
public string MethodC()
{
return "调用SubSystemC的方法";
}
}
/// <summary>
/// 子系统D
/// </summary>
public class SubSystemD
{
public string MethodD()
{
return "调用SubSystemD的方法";
}
}
/// <summary>
/// 外观模式
/// </summary>
public class Facade
{
SubSystemA SystemA;
SubSystemB SystemB;
SubSystemC SystemC;
SubSystemD SystemD;
public List<string> ls ;
public Facade()
{
SystemA = new SubSystemA();
SystemB = new SubSystemB();
SystemC = new SubSystemC();
SystemD = new SubSystemD();
ls = new List<string>();
}
public void FacadeMethodA()
{
ls.Add(SystemA.MethodA());
ls.Add(SystemB.MethodB());
}
public void FacadeMethodB()
{
ls.Add(SystemA.MethodA());
ls.Add(SystemC.MethodC());
ls.Add(SystemD.MethodD());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -