Ejemplo n.º 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();
        }
Ejemplo n.º 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();

        }
Ejemplo n.º 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();
        }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            var builder  = new ConcreteBuilder();
            var director = new Director(builder);
            var product  = director.Build();

            Console.WriteLine(product);
        }
Ejemplo n.º 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
        }