Пример #1
0
        public async Task <SanityCheckResult> Check(Type[] types, BootLog log)
        {
            var result = new SanityCheckResult();

            foreach (var type in types)
            {
                try
                {
                    var check = (ICheckSanity)serviceLocator.GetService(type);
                    var sane  = await check.Probe();

                    result.Add(type, sane);
                    if (sane)
                    {
                        log.Info(Constants.BootComponents.SanityChecks, $"{type.Name} passed.");
                    }
                    else
                    {
                        log.Error(Constants.BootComponents.SanityChecks, $"{type.Name} failed.");
                    }
                }
                catch (Exception)
                {
                    result.Add(type, false);
                    log.Error(Constants.BootComponents.SanityChecks, $"{type.Name} failed significantly.");
                }
            }

            return(result);
        }
        internal void RegisterServices(IServiceRegistration[] registrations, BootLog log)
        {
            Container = new Container();
            foreach (var registration in registrations)
            {
                log?.Info("ServiceLocator", $"Loading Services {registration.GetType().Name}");
                registration.RegisterServices(Container);
            }

            Container.Register <IServiceLocator>(() => this, Lifestyle.Singleton);
        }