Beispiel #1
0
        /// <summary>
        /// 在程序宿主环境开始启动时刻,要处理的逻辑
        /// </summary>
        /// <param name="context">启动上下文</param>
        void IStartupService.OnStarting(StartupContext context)
        {
            var providers = this.initApiRouteProvider == null ? null : this.initApiRouteProvider.Invoke(this.a10HealthReport);

            if (providers.IsNullOrEmpty())
            {
                return;
            }

            var type = typeof(ApiUriDispatcher <>);

            foreach (var p in providers)
            {
                var gtype    = type.MakeGenericType(p.GetType());
                var instance = Activator.CreateInstance(gtype, p, this.a10HealthReport);
                if (this.LoggerBuilder != null && instance is IApiRouteLogTracker)
                {
                    ((IApiRouteLogTracker)instance).LoggerBuilder = this.LoggerBuilder;
                }

                context.ServiceRegister.RegisterInstance(instance, gtype);
            }

            a10HealthReport.Startup(this.secondInterval, providers);
        }