private static AbstractPlatform configurationPlatform() { AbstractPlatform _platform; IGUIFactory _gUIFactory; string _osName = Environment.OSVersion.ToString(); if (_osName.Contains("mac")) { _gUIFactory = new MacOSFactory(); _platform = new AbstractPlatform(_gUIFactory); } else { _gUIFactory = new WindowsFactory(); _platform = new AbstractPlatform(_gUIFactory); } return(_platform); }
/** * EN: Application picks the factory type and creates it in run time * (usually at initialization stage), depending on the configuration or * environment variables. * * RU: Приложение выбирает тип и создаёт конкретные фабрики динамически * исходя из конфигурации или окружения. */ private static Application ConfigureApplication() { Application app; IGuiFactory factory; String osName = System.Environment.GetEnvironmentVariable("OS").ToLower(); if (osName.Contains("mac")) { factory = new MacOSFactory(); app = new Application(factory); } else { factory = new WindowsFactory(); app = new Application(factory); } return(app); }