Beispiel #1
0
 public RedisSubscribeTests()
 {
     InitConfig.Init();
 }
Beispiel #2
0
 public AliyunSubscribeTests()
 {
     InitConfig.Init();
 }
Beispiel #3
0
 public RedisCacheTest()
 {
     InitConfig.Init();
 }
 public DefaultStringLocalizerTest()
 {
     InitConfig.Init();
 }
Beispiel #5
0
 public LogTests()
 {
     InitConfig.Init();
 }
Beispiel #6
0
 public RabbitMQSubscribeTests()
 {
     InitConfig.Init();
 }
 public XmlStringLocalizerTest()
 {
     InitConfig.Init();
 }
Beispiel #8
0
 public Log4netTests()
 {
     InitConfig.Init();
 }
Beispiel #9
0
 public MEFTests()
 {
     InitConfig.Init();
 }
Beispiel #10
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment env,
                              IMsgReceive msgHandler,
                              IApplicationLifetime applicationLifetime)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                app.UseHsts();
            }
            InitConfig.Init(app.ApplicationServices);

            //日志记录中间件
            //repository = LogManager.CreateRepository("NETCoreRepository");
            //XmlConfigurator.Configure(repository, new FileInfo("log4net.config"));
            app.UseStatusCodePages();
            app.UseStaticFiles();

            #region websocket

            #region 基础websocket
            //var webSocketOptions = new WebSocketOptions()
            //{
            //    KeepAliveInterval = TimeSpan.FromSeconds(120),
            //    ReceiveBufferSize = 4 * 1024
            //};
            //app.UseWebSockets(webSocketOptions);
            //app.UseCustomWebSocketManager();
            #endregion

            #region SignalR
            //初始化数据库
            // 使用SignalR 并添加MessageHub类的消息处理器
            //app.UseSignalR(r =>
            //{
            //    r.MapHub<MessageHub>("/messagehub", options => options.WebSockets.SubProtocolSelector = requestedProtocols =>
            //    {
            //        return requestedProtocols.Count > 0 ? requestedProtocols[0] : null;
            //    });
            //});
            #endregion

            #endregion

            app.UseSession();
            //gzip压缩中间件
            app.UseResponseCompression();
            //Response 缓存中间件
            app.UseResponseCaching();

            #region Cors
            //app.UseCors("SANS跨域策略");

            #endregion

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "areas",
                    template: "{area:exists}/{controller}/{action=Index}/{id?}"
                    );
                routes.MapRoute(
                    name: "default",
                    template: "{controller=User}/{action=Login}/");
            });
            // 应用启动时开始处理消息
            applicationLifetime.ApplicationStarted.Register(msgHandler.receiveMsg);
            applicationLifetime.ApplicationStopping.Register(msgHandler.stopMsg);
            // 应用退出时,释放资源

            #region Swagger
            //app.UseSwagger();
            //app.UseSwaggerUI(c =>
            //{
            //    c.SwaggerEndpoint("/swagger/v1/swagger.json", "KNAPI");
            //});
            #endregion
        }