public void InstallServices(IServiceProvider map) { _core = map.GetService(typeof(Core)) as Core; _config = map.GetService(typeof(Config)) as Config; _hueClient = map.GetService(typeof(HueCore)) as HueCore; _screen = map.GetService(typeof(ScreenReader)) as ScreenReader; }
private IServiceProvider ConfigureServices(bool isHeadless) { //setup and add command service. _input = new InputHandler(isHeadless); _core = new Core(); _screen = new ScreenReader(); _zoneProcesser = new ZoneProcessor(); _hueClient = new HueCore(); _rgbLighter = new RGBLighter(); _stripLighter = new StripLighter(); _socketServer = new SocketHandler(); var services = new ServiceCollection(); if (_config.Model.ffmpegCaptureSettings.useFFMpeg) { services .AddScoped <FileLogger>() .AddSingleton(_config) .AddSingleton(_input) .AddSingleton(_core) .AddSingleton(_hueClient) .AddSingleton(_screen) .AddSingleton(_zoneProcesser) .AddSingleton(_stripLighter) .AddSingleton(_socketServer); } else { services .AddScoped <FileLogger>() .AddSingleton(_config) .AddSingleton(_input) .AddSingleton(_core) .AddSingleton(_hueClient) .AddSingleton(_screen) .AddSingleton(_zoneProcesser) .AddSingleton(_rgbLighter) .AddSingleton(_stripLighter) .AddSingleton(_socketServer); } var provider = new DefaultServiceProviderFactory().CreateServiceProvider(services); return(provider); }