// 代理模式 为其他对象提供一种代理以控制这个对象的访问。 static void Proxy() { SchoolGirl girl = new SchoolGirl("李娇娇"); Proxy proxy = new Proxy(girl); proxy.GiveDolls(); proxy.GiveFlowers(); proxy.GiveChocolate(); }
public Pursuit(SchoolGirl mm) { this.mm = mm; }
public Proxy(SchoolGirl mm) { gg = new Pursuit(mm); }
public Proxy(SchoolGirl gril) { pursuit = new Pursuit(gril); }
static void Main(string[] args) { #if DECORATOR Person ms = new Person("MarsonShine"); Console.WriteLine("\n 第一种妆扮:"); TShirts dtx = new TShirts(); BigTrouser bt = new BigTrouser(); dtx.Decorate(ms); bt.Decorate(dtx); bt.Show(); #endif #if Proxy SchoolGirl zhuqin = new SchoolGirl(); zhuqin.Name = "祝琴"; Proxy.Proxy ms = new Proxy.Proxy(zhuqin); ms.GiveChocolate(); ms.GiveDolls(); ms.GiveFlowers(); Console.ReadLine(); #endif #if ChanOfResposibility HandsetBrand hb; hb = new HandsetBrandN(); hb.SetHandsetSoft(new HandsetGame()); hb.Run(); hb.SetHandsetSoft(new HandsetAddressList()); hb.Run(); HandsetBrand hb2; hb2 = new HandsetBrandM(); hb2.SetHandsetSoft(new HandsetGame()); hb2.Run(); hb2.SetHandsetSoft(new HandsetAddressList()); hb2.Run(); #endif #if ChainOfResiposibility CommonManager jinli = new CommonManager("jinli"); Majordomo zongjian = new Majordomo("zongjian"); GeneralManager zhongjingli = new GeneralManager("zhongjinli"); jinli.SetSuperior(jinli); zongjian.SetSuperior(zhongjingli); Request request = new Request(); request.RequestType = "请假"; request.RequestContent = "我要请假"; request.Number = 1; jinli.RequestApplications(request); Request request2 = new Request(); request2.RequestType = "请假"; request2.RequestContent = "我要请假"; request.Number = 4; jinli.RequestApplications(request2); Request request3 = new Request(); request3.RequestType = "请假"; request3.RequestContent = "我还是要请假"; request.Number = 500; jinli.RequestApplications(request3); #endif ObjectStructure o = new ObjectStructure(); o.Attach(new Man()); o.Attach(new Woman()); Success v1 = new Success(); o.Display(v1); Failing v2 = new Failing(); o.Display(v2); }