Beispiel #1
0
        static void Main(string[] args)
        {
            var buildDirector = new Director();

            Buildings.Add(buildDirector.Build(new CastleBuilder()));
            Buildings.Add(buildDirector.Build(new HouseBuilder()));
            Buildings.Add(buildDirector.Build(new HutBuilder()));

            foreach (var building in Buildings)
            {
                Console.WriteLine(building);
            }

            Console.ReadKey();
        }
Beispiel #2
0
        private void btnGetDatabase_Click(object sender, EventArgs e)
        {
            Director director = new Director();
            IDatabaseBuilder builder;

            if (radUseSqlServer.Checked)
            {
                builder = new SqlServerDatabaseBuilder();
            }
            else
            {
                builder = new OleDbDatabaseBuilder();
            }

            director.Build(builder);
            Database database = builder.Database;

            DbCommand command = database.Command;
            // now, we can do something, like:
            //command.CommandText = "SELECT * FROM Customers";
            //command.Connection.Open();
            //DbDataReader reader = command.ExecuteReader();

            //reader.Close();
            //command.Connection.Close();

        }
Beispiel #3
0
        private void btnGetDatabase_Click(object sender, EventArgs e)
        {
            Director         director = new Director();
            IDatabaseBuilder builder;

            if (radUseSqlServer.Checked)
            {
                builder = new SqlServerDatabaseBuilder();
            }
            else
            {
                builder = new OleDbDatabaseBuilder();
            }

            director.Build(builder);
            Database database = builder.Database;

            DbCommand command = database.Command;
            // now, we can do something, like:
            //command.CommandText = "SELECT * FROM Customers";
            //command.Connection.Open();
            //DbDataReader reader = command.ExecuteReader();

            //reader.Close();
            //command.Connection.Close();
        }
        public static void Main(string[] args)
        {
            var builder  = new ConcreteBuilder();
            var director = new Director(builder);
            var product  = director.Build();

            Console.WriteLine(product);
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            #region Client

            Director director = new Director();

            IPhoneBuilder phoneBuilder;

            //Create andriod
            phoneBuilder = new AndroidPhoneBuilder();
            director.Build(phoneBuilder);

            MobilePhone phone = phoneBuilder.Phone; 
            #endregion
        }