static Client GetClientOS() { IFactory concreteFactory; string OSName = RuntimeInformation.OSDescription.ToUpper(); if (OSName.Contains("WINDOWS")) { concreteFactory = new WinFactory(); } else if (OSName.Contains("MAC")) { concreteFactory = new MacFactory(); } else { throw new ArgumentException("Sistema operacional incompatível"); } return(new Client(concreteFactory)); }
static void Main(string[] args) { System.Console.WriteLine("Introduce OS name:"); string OS = Console.ReadLine(); IGUIFactory guiFactory; switch (OS) { case "Windows": default: guiFactory = new WinFactory(); break; case "Mac": guiFactory = new MacFactory(); break; } Application app = new Application(guiFactory); app.Paint(); }