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(); }
public static void Show() { // 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()); }
public static void Main(string[] args) { IBuilder builder = new ConcreteBuilder(); Director director = new Director(builder); director.Construct(); Product product = builder.GetResult(); Console.WriteLine($"Size: {product.Size}\nColor: {product.Color}"); }
static void Main(string[] args) { Builder b1 = new ConcreteBuilder(); Director d = new Director(b1); d.Construct(); b1.GetResult().Show(); Console.ReadKey(); }
static void Main(string[] args) { var director = new ExecuteBuilding(); var builder = new ConcreteBuilder(); director.Builder = builder; Console.WriteLine("Basic house: "); director.buildBasicHouse(); Console.WriteLine(builder.GetHouse().ListParts()); Console.WriteLine("\nStandard full featured house: "); director.buildFullFeaturedHouse(); Console.WriteLine(builder.GetHouse().ListParts()); Console.WriteLine("\nCustom house:"); director.buildBasicHouse(); builder.BuildGarden(); Console.Write(builder.GetHouse().ListParts()); }
public 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(); Console.WriteLine("Standard full featured product: "); director.BuildFullFeaturedProduct(); Console.WriteLine(builder.GetProduct().ListParts()); Console.WriteLine(); Console.WriteLine("Custom product: "); builder.BuildPartA(); builder.BuildPartC(); Console.WriteLine(builder.GetProduct().ListParts()); }