private async Task LoadServices() { var services = Instatiate <IServicePlugin>(_pendingServices); foreach (var s in services) { if (await s.Initialize()) { s.Implements.ForEach(e => _injector.RegisterService(e, s.GetType(), s.LifeCycle)); _rip.Register(s.GetType(), true); _success.Add(s); _logger.Debug($"Service Plugin loaded: {s.Info.Name}"); } else { _failed.Add(s); _logger.Warning($"Failed to load Service Plugin: {s.Info.Name}"); } } }
private IHost BuildHost() { injector.RegisterService(() => BuildMockHostProps(), LifeCycle.Singleton); injector.RegisterService(() => new MopLifeService(new CancellationToken()), LifeCycle.Singleton); injector.RegisterService(() => injector, LifeCycle.Singleton); injector.RegisterService <IHost, MopHost>(LifeCycle.Singleton); injector.RegisterService <ILogService, LogService>(LifeCycle.Singleton); injector.RegisterService <IConfigService, ConfigService>(LifeCycle.Singleton); if (injector.GetService <IHost>() is MopHost host) { return(host); } throw new Exception("Failed to instantiate host"); }