static void Main(string[] args) { /* Begin demonstration of Abstract Factory design pattern */ /* Note that Program.cs (driver class) has no knowledge of the interfaces/factories involved*/ /* It creates concrete factories and shapes/colors from the interfaces, as opposed to their concrete classes*/ // create a shape factory using factory generator IFactory shapeFactory = FactoryGenerator.GenerateFactory("shape"); // create a color factory using the factory generator IFactory colorFactory = FactoryGenerator.GenerateFactory("color"); // create shapes from the abstract IFactory IShape rectangle = shapeFactory.CreateShape("rectangle"); IShape square = shapeFactory.CreateShape("square"); // create colors from the abstract IFactory IColor green = colorFactory.CreateColor("green"); IColor red = colorFactory.CreateColor("red"); // verify that the abstract colors and shapes display the correct output green.Colorize(); rectangle.Draw(); red.Colorize(); square.Draw(); // view console output of the program Console.Read(); }
public List <CodeFile> Generate(List <ModelClass> modelClasses, List <string> dependencies, List <string> factoryFields) { var codeFiles = modelClasses .SelectMany(mC => { var files = new List <CodeFile> { fGenerator.GenerateFactory(mC), mClassGenerator.GenerateModelClassFile(mC), dGenerator.GenerateModelClassFile(mC) }; files.AddRange(changedGenerator.GenerateChanged(mC)); return(files); }) .Where(c => c != null).ToList(); codeFiles.Add(factoryProviderGenerator.GenerateProvider(modelClasses, dependencies, factoryFields)); return(codeFiles); }