static void Main(string[] args) { Console.WriteLine("Builder Patterns - Creation Pattern"); Director director = new Director(); IDatabaseBuilder builder; string command = null; while (true) { command = Console.ReadLine(); if (command == "ole") { builder = new OleDbDatabaseBuilder(); } else { builder = new SqlServerDatabaseBuilder(); } director.Build(builder); Database db = builder.Database; Console.WriteLine(db.DatabaseType); } }
static void Main(string[] args) { Console.WriteLine(FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion); Builder HPBuilder = ObjectManager.CreateObject <HPBuilder>(); Builder DellBuilder = ObjectManager.CreateObject <DellBuilder>(); Builder[] builders = new Builder[] { HPBuilder, DellBuilder }; Director director = ObjectManager.CreateObject <Director>(builders); director.Build <HPBuilder>(); director.Build <DellBuilder>(); Computer HPComputer = HPBuilder.GetComputer(); Computer DellComputer = DellBuilder.GetComputer(); HPComputer.ShowResults(); DellComputer.ShowResults(); Console.ReadLine(); }