Beispiel #1
0
        private static void Initialize()
        {
            ICacheProvider provider = new RuntimeMemoryCacheProvider();
            CacheManager.SetProvider(provider, CacheLevel.First);

            IServicesBuilder builder = new ServicesBuilder(new ServiceBuildOptions());
            IServiceCollection services = builder.Build();
            services.AddLog4NetServices();
            services.AddDataServices();

            IFrameworkInitializer initializer = new FrameworkInitializer();

            initializer.Initialize(services, new MvcAutofacIocBuilder());
            initializer.Initialize(services, new WebApiAutofacIocBuilder());
            initializer.Initialize(services, new SignalRAutofacIocBuilder());
        }
Beispiel #2
0
        public void Configuration(IAppBuilder app)
        {
            // 有关如何配置应用程序的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkID=316888

            ICacheProvider provider = new RuntimeMemoryCacheProvider();
            CacheManager.SetProvider(provider, CacheLevel.First);

            IServicesBuilder builder = new ServicesBuilder(new ServiceBuildOptions());
            IServiceCollection services = builder.Build();
            services.AddLog4NetServices();
            services.AddDataServices();

            app.UseOSkyMvc(services, new MvcAutofacIocBuilder());
            app.UseOSkyWebApi(services, new WebApiAutofacIocBuilder());
            app.UseOSkySignalR(services, new SignalRAutofacIocBuilder());

            ConfigurationWebApi(app);
            ConfigureSignalR(app);

            // 使应用程序可以使用 Cookie 来存储已登录用户的信息
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Admin/Login/Index"),
                ExpireTimeSpan = TimeSpan.FromMinutes(20),    //20分钟过期
                SlidingExpiration=true
            });

            //// Use a cookie to temporarily store information about a user logging in with a third party login provider
            //app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            //// 取消注释以下行可允许使用第三方登录提供程序登录
            //app.UseMicrosoftAccountAuthentication(
            //    clientId: "",
            //    clientSecret: "");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "",
            //   appSecret: "");

            // 支持使用 google 账户登录
            //app.UseGoogleAuthentication();
        }