當前位置: 首頁>>代碼示例>>C#>>正文


C# Container.GetOwinContext方法代碼示例

本文整理匯總了C#中SimpleInjector.Container.GetOwinContext方法的典型用法代碼示例。如果您正苦於以下問題:C# Container.GetOwinContext方法的具體用法?C# Container.GetOwinContext怎麽用?C# Container.GetOwinContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SimpleInjector.Container的用法示例。


在下文中一共展示了Container.GetOwinContext方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetInitializeContainer

        public static Container GetInitializeContainer(
                  IAppBuilder app)
        {
            var container = new Container();
 
            container.RegisterSingleton(app);
 
            container.RegisterConditional(typeof(IRepository<>), typeof(Repository<>), c => !c.Handled);
 
            container.RegisterPerWebRequest<IDragonUserStore<AppMember>>(() =>
                new Dragon.SecurityServer.ChainedIdentity.Stores.UserStore<AppMember>(new List<IDragonUserStore<AppMember>>{
                    new UserStore<AppMember>(new Repository<AppMember>(), new Repository<IdentityUserClaim>(), new Repository<IdentityUserLogin>(), null, null)
                }));
 
            container.RegisterPerWebRequest(() => ApplicationUserManager.Create(container));

            container.RegisterPerWebRequest(() => container.GetOwinContext().Authentication);

            container.RegisterMvcControllers(
                    Assembly.GetExecutingAssembly());
            
            return container;
        }
開發者ID:aduggleby,項目名稱:dragon,代碼行數:23,代碼來源:SimpleInjectorInitializer.cs

示例2: GetInitializeContainer

        public static Container GetInitializeContainer(
                  IAppBuilder app)
        {
            var container = new Container();
            container.Options.PropertySelectionBehavior = new ImportPropertySelectionBehavior(); // Enable ImportAttribute for property injection
 
            container.RegisterSingleton(app);

            container.Register<IFederationService, FederationService>(Lifestyle.Singleton);
            container.Register<IAppService, AppService>(Lifestyle.Transient);
 
            container.RegisterConditional(typeof(IRepository<>), typeof(Repository<>), c => !c.Handled);

            container.Register<ICheckPasswordService<AppMember>, LegacyCheckPasswordService<AppMember>>(Lifestyle.Transient);
 
            container.RegisterPerWebRequest<IDragonUserStore<AppMember>>(() =>
            {
                var dragonUserStores = new List<IDragonUserStore<AppMember>>
                {
                    new UserStore<AppMember>(new Repository<AppMember>(), null, new Repository<IdentityUserLogin>(),
                        new Repository<IdentityUserService>(), new Repository<IdentityUserApp>())
                };
                if (WebConfigurationManager.ConnectionStrings[RedisConnectionStringName] != null)
                {
                    var connectionMultiplexer = ConnectionMultiplexer.Connect(WebConfigurationManager.ConnectionStrings[RedisConnectionStringName].ConnectionString);
                    connectionMultiplexer.PreserveAsyncOrder = false;
                    dragonUserStores.Insert(0, new Identity.Redis.UserStore<AppMember>(new RedisUserStore<Identity.Redis.IdentityUser>(connectionMultiplexer), connectionMultiplexer));
                }
                var userStore = new ChainedIdentity.Stores.UserStore<AppMember>(dragonUserStores);
                Startup.OpenIdMigrationWebrequestHandler = new OpenIdMigrationWebRequestHandler(userStore);
                return userStore;
            });

            container.Register<IUserService, UserService>(Lifestyle.Transient);

            container.RegisterPerWebRequest(() => ApplicationUserManager.Create(container, Startup.DataProtectionProvider));

            container.RegisterPerWebRequest(() => container.GetOwinContext().Authentication);

            container.RegisterMvcControllers(
                    Assembly.GetExecutingAssembly());
            
            return container;
        }
開發者ID:aduggleby,項目名稱:dragon,代碼行數:44,代碼來源:SimpleInjectorInitializer.cs


注:本文中的SimpleInjector.Container.GetOwinContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。