static void Main(string[] args) { var factory = Factory.GetFactory(args[0]); Link asahi = factory.CreateLink("朝日新聞", "http://www.asahi.com/"); Link yomiuri = factory.CreateLink("読売新聞", "http://www.yomiuri.co.jp/"); Link us_yahoo = factory.CreateLink("Yahoo!", "http://www.yahoo.com/"); Link jp_yahoo = factory.CreateLink("Yahoo!Japan", "http://www.yahoo.co.jp/"); Link excite = factory.CreateLink("Excite", "http://www.excite.com/"); Link google = factory.CreateLink("Google", "http://www.google.com/"); Tray trayNews = factory.CreateTray("新聞"); trayNews.Add(asahi); trayNews.Add(yomiuri); Tray trayYahoo = factory.CreateTray("Yahoo!"); trayYahoo.Add(us_yahoo); trayYahoo.Add(jp_yahoo); Tray traySearch = factory.CreateTray("サーチエンジン"); traySearch.Add(trayYahoo); traySearch.Add(excite); traySearch.Add(google); Page page = factory.CreatePage("LinkPage", "結城 浩"); page.Add(trayNews); page.Add(traySearch); page.Output(); }
public static void Main(string[] args) { if (args.Length != 1) { const string ListFactoryClass = "Gushwell.DesignPatterns.List.ListFactory"; const string TableFactoryClass = "Gushwell.DesignPatterns.Table.TableFactory"; Console.WriteLine("Usage: AbstractFactory TypeName"); Console.WriteLine("Example 1: AbstractFactory " + ListFactoryClass); Console.WriteLine("Example 2: AbstractFactory " + TableFactoryClass); return; } Factory factory = Factory.GetFactory(args[0]); Link asahi = factory.CreateLink("朝日新聞", "http://www.asahi.com/"); Link yomiuri = factory.CreateLink("読売新聞", "http://www.yomiuri.co.jp/"); Link us_yahoo = factory.CreateLink("Yahoo!", "http://www.yahoo.com/"); Link jp_yahoo = factory.CreateLink("Yahoo!Japan", "http://www.yahoo.co.jp/"); Link excite = factory.CreateLink("Excite", "http://www.excite.com/"); Link google = factory.CreateLink("Google", "http://www.google.com/"); Tray traynews = factory.CreateTray("新聞"); traynews.Add(asahi); traynews.Add(yomiuri); Tray trayyahoo = factory.CreateTray("Yahoo!"); trayyahoo.Add(us_yahoo); trayyahoo.Add(jp_yahoo); Tray traysearch = factory.CreateTray("サーチエンジン"); traysearch.Add(trayyahoo); traysearch.Add(excite); traysearch.Add(google); Page page = factory.CreatePage("LinkPage", "結城 浩"); page.Add(traynews); page.Add(traysearch); page.Output(); }
static void Main(string[] args) { if (args.Length != 1) { Console.WriteLine("Usage: C# Main class.name.of.ConcreteFactory"); Console.WriteLine("Example 1: C# Main ListFactory.ListFactory"); Console.WriteLine("Example 2: C# Main TableFactory.TableFactory"); Environment.Exit(0); } Factory factory = Factory.GetFactory(args[0]); Link asahi = factory.CreateLink("朝日新聞", "http://www.asashi.com/"); Link yomiuri = factory.CreateLink("読売新聞", "http://www.yomiuri.co.jp/"); Link usYahoo = factory.CreateLink("Yahoo!", "http://www.yahoo.com/"); Link jpYahoo = factory.CreateLink("Yahoo!Japan", "http://www.yahoo.co.jp/"); Link excite = factory.CreateLink("Excite", "http://www.excite.co.jp/"); Link google = factory.CreateLink("Google", "http://www.google.com/"); Tray traynews = factory.CreateTray("新聞"); traynews.Add(asahi); traynews.Add(yomiuri); Tray trayyahoo = factory.CreateTray("Yahoo!"); trayyahoo.Add(usYahoo); trayyahoo.Add(jpYahoo); Tray traysearch = factory.CreateTray("サーチエンジン"); traysearch.Add(trayyahoo); traysearch.Add(excite); traysearch.Add(google); Page page = factory.CreatePage("LinkPage", "結城 浩"); page.Add(traynews); page.Add(traysearch); page.Output(); }