示例#1
0
        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));
        }
示例#2
0
        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();
        }