예제 #1
0
        /// <summary>
        /// 初始化,必须先调用
        /// </summary>
        public static void InitializeBase(bool bear)
        {
            if (IsInitialize)
            {
                return;
            }

            IocHelper.Update();
            IocHelper.AddScoped <GlobalContext, BusinessContext>();
            IocHelper.AddSingleton <IZeroPublisher, ZeroNetBridge>();
            IocHelper.AddSingleton <IGlobalContext, BusinessContext>(p => BusinessContext.Context);
            IocHelper.Update();

            Environment.CurrentDirectory = ConfigurationManager.BasePath = HttpContext.Current.Server.MapPath("~");

            LogRecorder.Initialize();
            LogRecorder.SystemLog("启动");
            LogRecorder.GetRequestIdFunc = () => RandomOperate.Generate(8);
            GlobalConfiguration.Configuration.MapHttpAttributeRoutes(new CustomDirectRouteProvider());
            HttpHandler.Handlers.Add(new CorsHandler());
            HttpHandler.Handlers.Add(new HttpIoLogHandler());
            if (bear)
            {
                HttpHandler.Handlers.Add(new BearerHandler());
            }
            IsInitialize = true;
        }
예제 #2
0
 /// <summary>
 /// 初始化
 /// </summary>
 public static void Initialize()
 {
     // 日志支持
     //Agebull.Common.Logging.LogRecorder.GetRequestIdFunc = () => ApiContext.RequestContext.RequestId;.
     LogRecorder.Initialize(new RemoteRecorder());
     AppConfig.Initialize(Path.Combine(Startup.Configuration["contentRoot"], "route_config.json"));
     StationProgram.Run();
     RouteChahe.Flush();
     RuntimeWaring.Flush();
     RouteCommand.ZeroFlush();
     //Datas = new List<RouteData>();
 }