コード例 #1
0
ファイル: BuilderPatternTests.cs プロジェクト: prnawa/DPSharp
        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);
        }
コード例 #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();
    }
コード例 #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();
    }
コード例 #4
0
    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( );
        }
コード例 #5
0
            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();

            }