Пример #1
0
    public static void Main()
    {
        var director = new Director();
        var builder  = new ConcreteBuilder();

        director.Builder = builder;

        Console.WriteLine("Standard basic product:");
        director.BuildMinimalViableProduct();
        Console.WriteLine(builder.GetProduct().ListParts());

        Console.WriteLine("Standard full featured product:");
        director.BuildFullFeaturedProduct();
        Console.WriteLine(builder.GetProduct().ListParts());

        var breadBuilder = new BreadBuilder();

        director.Builder = breadBuilder;
        Console.WriteLine("Standard basic product:");
        director.BuildMinimalViableProduct();
        Console.WriteLine(breadBuilder.GetProduct().ListParts());

        Console.WriteLine("Standard full featured product:");
        director.BuildFullFeaturedProduct();
        Console.WriteLine(breadBuilder.GetProduct().ListParts());

        Console.WriteLine("Custom product:");
        builder.BuildPartA();
        builder.BuildPartC();
        Console.Write(builder.GetProduct().ListParts());
        Console.ReadKey();
    }
        public void Main()
        {
            // The client code creates a builder object, passes it to the
            // director and then initiates the construction process. The end
            // result is retrieved from the builder object.
            var director = new Director();
            var builder  = new ConcreteBuilder();

            director.Builder = builder;

            Console.WriteLine("Standard basic product:");
            director.buildMinimalViableProduct();
            Console.WriteLine(builder.GetProduct().ListParts());

            Console.WriteLine("Standard full featured product:");
            director.buildFullFeaturedProduct();
            Console.WriteLine(builder.GetProduct().ListParts());

            // Remember, the Builder pattern can be used without a Director
            // class.
            Console.WriteLine("Custom product:");
            builder.BuildPartA();
            builder.BuildPartC();
            Console.Write(builder.GetProduct().ListParts());
        }
Пример #3
0
    static void Main(string[] args)
    {
        Director        director = new Director();
        ConcreteBuilder builder  = new ConcreteBuilder();

        director.Builder = builder;

        Console.WriteLine("Standard basic product:");
        director.buildMinimalViableProduct();
        Console.WriteLine(builder.GetProduct().ListParts());

        Console.WriteLine("Standard full featured product:");
        director.buildFullFeaturedProduct();
        Console.WriteLine(builder.GetProduct().ListParts());

        Console.WriteLine("Custom product:");
        builder.BuildPartA();
        builder.BuildPartC();
        Console.Write(builder.GetProduct().ListParts());
    }
Пример #4
0
        private static void ExecutarBuilder()
        {
            var director = new Director();
            var builder  = new ConcreteBuilder();

            director.Builder = builder;

            Console.WriteLine("Standard basic product:");
            director.BuildMinimalViableProduct();
            Console.WriteLine(builder.GetProduct().ListParts());

            Console.WriteLine("Standard full featured product:");
            director.BuildFullFeaturedProduct();
            Console.WriteLine(builder.GetProduct().ListParts());

            Console.WriteLine("Custom product:");
            builder.BuildPartA();
            builder.BuildPartC();
            Console.Write(builder.GetProduct().ListParts());
        }
Пример #5
0
        static void Main(string[] args)
        {
            var director = new Director();
            var builder  = new ConcreteBuilder();

            director.Builder = builder;

            Console.WriteLine("Standard basic product:");
            director.buildMinimalViableProduct();
            Console.WriteLine(builder.GetProduct().ListParts());

            Console.WriteLine("Standard full featured product:");
            director.buildFullFeaturedProduct();
            Console.WriteLine(builder.GetProduct().ListParts());

            //Remember, the builder pattern can be used without a director class
            Console.WriteLine("Custom product:");
            builder.BuildPartA();
            builder.BuildPartC();
            Console.WriteLine(builder.GetProduct().ListParts());
        }
Пример #6
0
        public void BuilderTest()
        {
            // The client code creates a builder object, passes it to the
            // director and then initiates the construction process. The end
            // result is retrieved from the builder object.
            var director = new Director();
            var builder  = new ConcreteBuilder();

            director.Builder = builder;

            // Create a standard basic product
            director.BuildMinimalViableProduct();
            builder.GetProduct().ListParts().Should().ContainInOrder(Text.PartA);

            // Create a standard full featured product
            director.BuildFullFeaturedProduct();
            builder.GetProduct().ListParts().Should().ContainInOrder(Text.PartA, Text.PartB, Text.PartC);

            // Remember, the Builder pattern can be used without a Director
            // class.
            builder.BuildPartA();
            builder.BuildPartC();
            builder.GetProduct().ListParts().Should().ContainInOrder(Text.PartA, Text.PartC);
        }