Пример #1
0
        static void TestSample2()
        {
            // Create director and builders

            Director director = new Director();

            Builder b1 = new ConcreteBuilderA();
            Builder b2 = new ConcreteBuilderB();

            // Construct two products

            director.Construct(b1);
            Product p1 = b1.GetResult();

            p1.ShowParts();

            director.Construct(b2);
            Product p2 = b2.GetResult();

            p2.ShowParts();

            // Wait for user

            System.Console.ReadKey();
        }
Пример #2
0
        public void BuilderPatternCodeTest()
        {
            ConcreteBuilderA concreteBuilderA = new ConcreteBuilderA();
            ConcreteBuilderB concreteBuilderB = new ConcreteBuilderB();

            Director director = new Director();

            director.Construct(concreteBuilderA);
            var aProcudt = concreteBuilderA.GetResult();

            aProcudt.Show();

            director.Construct(concreteBuilderB);
            var bProduct = concreteBuilderB.GetResult();

            bProduct.Show();
        }