Esempio n. 1
0
        public void Test()
        {
            var     director = new Director();
            Builder builder  = null;

            builder = new Builder1();
            director.Construct(builder);
            var result1 = builder.GetResult();

            builder = new Builder2();
            director.Construct(builder);
            var result2 = builder.GetResult();

            Assert.AreEqual("Part A", result1.PartOne);
            Assert.AreEqual("Part B", result1.PartTwo);

            Assert.AreEqual("Part X", result2.PartOne);
            Assert.AreEqual("Part Y", result2.PartTwo);
        }
Esempio n. 2
0
    public static void MainRun()
    {
        // Create one director and two builders
        Director director = new Director();

        IBuilder b1 = new Builder1();
        IBuilder b2 = new Builder2();

        // Construct two products
        director.Construct(b1);
        Product p1 = b1.GetResult();

        p1.Display();

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

        p2.Display();
    }
Esempio n. 3
0
    public static void Main()
    {
        Director director = new Director();

        var b1 = new Builder1();
        var b2 = new Builder2();

        director.SetBuilder(b1);
        director.Construct();
        var p1 = b1.GetResult();

        p1.Display();

        director.SetBuilder(b2);
        director.Construct();
        var p2 = b2.GetResult();

        p2.Display();

        Console.ReadKey();
    }
    public static void Main( ) 
        {
            // Create one director and two builders
            Director director = new Director( );

            IBuilder b1 = new Builder1( );
            IBuilder b2 = new Builder2( );

            // Construct two products
            director.Construct(b1);
            Product p1 = b1.GetResult( );
            p1.Display( );

            director.Construct(b2);
            Product p2 = b2.GetResult( );
            p2.Display( );
        }
            public static void RunMain()
            {
                IBuilder builder1 = new Builder1();
                IBuilder builder2 = new Builder2();
                Director director = new Director();
                director.Constructor(builder1);

                Product product = builder1.GetResult();
                product.Display();

                director.Constructor(builder2);
                product = builder2.GetResult();
                product.Display();

            }