Beispiel #1
0
        static void Main(string[] args)
        {
            //Client code creates a build object, passes it to the director,
            //then initiates the construction process. 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.BuildMinimalVialbleProduct();
            Console.WriteLine(builder.GetProduct().ListParts());

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

            //Builder patterns can also be used without a Director class
            Console.WriteLine("Custom product: ");
            builder.BuildPartA();
            builder.BuildPartC();
            Console.WriteLine(builder.GetProduct().ListParts());
            Console.ReadLine();
        }