爲子系統中的一組接口提供一個一致的調用接口,此模式定義了一個高層接口,這個接口使得這一子系統更加容易使用;
實現代碼:
internal class SystemOne
{
public void MethodOne()
{
Console.WriteLine("系統一的方法");
}
}
internal class SystemTwo
{
public void MethodTwo()
{
Console.WriteLine("系統二的方法");
}
}
internal class SystemThree
{
public void MethodThree()
{
Console.WriteLine("系統三的方法");
}
}
internal class SystemFour
{
public void MethodFour()
{
Console.WriteLine("系統四的方法");
}
}
internal class SystemFive
{
public void MethodFive()
{
Console.WriteLine("系統五的方法");
}
}
public class Facade
{
SystemOne one = new SystemOne();
SystemTwo two = new SystemTwo();
SystemThree three = new SystemThree();
SystemFour four = new SystemFour();
SystemFive five = new SystemFive();
public void One()
{
one.MethodOne();
three.MethodThree();
}
public void Two()
{
two.MethodTwo();
four.MethodFour();
}
public void Three()
{
five.MethodFive();
}
}
客戶端調用代碼:
Facade facade = new Facade();
facade.One();
facade.Three();