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


C# Container.IsVerifying方法代碼示例

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


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

示例1: Initialize

        public static void Initialize()
        {
            var container = new Container();
            container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();

            // Chamada dos módulos do Simple Injector
            InitializeContainer(container);

            // Necessário para registrar o ambiente do Owin que é dependência do Identity
            // Feito fora da camada de IoC para não levar o System.Web para fora
            container.RegisterPerWebRequest(() =>
            {
                if (HttpContext.Current != null && HttpContext.Current.Items["owin.Environment"] == null && container.IsVerifying())
                {
                    return new OwinContext().Authentication;
                }
                return HttpContext.Current.GetOwinContext().Authentication;

            });

            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

            container.Verify();

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
開發者ID:varcalsys,項目名稱:CONTABILIDADE_AERODRIGUES,代碼行數:26,代碼來源:SimpleInjectorInitializer.cs

示例2: RegisterServices

 public void RegisterServices(Container container)
 {
     container.RegisterPerWebRequest<IUserStore<User>>(() => new UserStore<User>(container.GetInstance<IdentityDbContext<User>>()));
     container.RegisterPerWebRequest(() => container.IsVerifying()
         ? new OwinContext(new Dictionary<string, object>()).Authentication
         : HttpContext.Current.GetOwinContext().Authentication);
 }
開發者ID:plamenyovchev,項目名稱:Bloggable,代碼行數:7,代碼來源:IdentityPackage.cs

示例3: Register

        public static void Register(HttpConfiguration config)
        {
            using (var container = new Container())
            {
                container.Options.DefaultScopedLifestyle = new WebApiRequestLifestyle();

                // Chamada dos módulos do Simple Injector
                BootStrapper.RegisterServices(container);

                // Necessário para registrar o ambiente do Owin que é dependência do Identity
                // Feito fora da camada de IoC para não levar o System.Web para fora
                container.RegisterPerWebRequest(() =>
                {
                    if (HttpContext.Current != null && HttpContext.Current.Items["owin.Environment"] == null && container.IsVerifying())
                    {
                        return new OwinContext().Authentication;
                    }
                    return HttpContext.Current.GetOwinContext().Authentication;

                });

                // This is an extension method from the integration package.
                container.RegisterWebApiControllers(config);

                container.Verify();

                GlobalConfiguration.Configuration.DependencyResolver =
                    new SimpleInjectorWebApiDependencyResolver(container);
            }
        }
開發者ID:thiagolunardi,項目名稱:IdentityIsolation,代碼行數:30,代碼來源:DependencyInjector.cs

示例4: ConfigureIoC

        public static void ConfigureIoC(HttpConfiguration config, Container container)
        {
            container.Options.DefaultScopedLifestyle = new ExecutionContextScopeLifestyle();
            container.RegisterWebApiRequest(() =>
            {
                if (HttpContext.Current != null && HttpContext.Current.Items["owin.Environment"] == null && container.IsVerifying())
                {
                    return new OwinContext().Authentication;
                }
                return HttpContext.Current.GetOwinContext().Authentication;

            });
            container.RegisterWebApiControllers(config, Assembly.GetExecutingAssembly());
            container.Register<ApplicationDbContext>(Lifestyle.Scoped);
            container.RegisterWebApiRequest<IUserStore<ApplicationUser>>(() => new UserStore<ApplicationUser>(new ApplicationDbContext()));
            container.Register<ApplicationUserManager>(Lifestyle.Scoped);
            container.Register<ApplicationSignInManager>(Lifestyle.Scoped);
            container.Verify();
            config.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container);
        }
開發者ID:gustavoferrazfontes,項目名稱:IdentityIsolation,代碼行數:20,代碼來源:Startup.cs

示例5: GetInitializedContainer

        public Container GetInitializedContainer(IAppBuilder app)
        {
            var container = new Container();

            container.RegisterSingle(app);


            //allows objects to be reused when inside web request, or created fresh when used on background threads or outside a request context
            var hybridLifestyle = Lifestyle.CreateHybrid(
                () => HttpContext.Current != null, new WebRequestLifestyle(), Lifestyle.Transient);

            container.RegisterPerWebRequest<TicketDeskContextSecurityProvider>();

            container.Register(() => new TdPushNotificationContext(), hybridLifestyle);

            container.Register(() => HttpContext.Current != null ?
                    new TdDomainContext(container.GetInstance<TicketDeskContextSecurityProvider>()) :
                    new TdDomainContext(),
                hybridLifestyle);

            container.Register(() => new TdIdentityContext(), hybridLifestyle);

            container.Register<IUserStore<TicketDeskUser>>(() =>
                new UserStore<TicketDeskUser>(container.GetInstance<TdIdentityContext>()), 
                hybridLifestyle);

            container.Register<IRoleStore<TicketDeskRole, string>>(() =>
                new RoleStore<TicketDeskRole>(container.GetInstance<TdIdentityContext>()), 
                hybridLifestyle);


            container.RegisterPerWebRequest(() =>
            {
                IOwinContext context;
                try
                {
                    context = HttpContext.Current.GetOwinContext();
                }
                catch (InvalidOperationException)
                {
                    //avoid exception when this is called before the owin environment is fully initialized
                    if (container.IsVerifying())
                    {
                        return new FakeAuthenticationManager();
                    }
                    throw;
                }

                return context.Authentication;
            }
                );

            container.RegisterPerWebRequest<SignInManager<TicketDeskUser, string>, TicketDeskSignInManager>();

            container.RegisterPerWebRequest<TicketDeskRoleManager>();

            container.RegisterInitializer<TicketDeskUserManager>(manager =>
                manager.ConfigureDataProtection(app));


            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

            return container;
        }
開發者ID:sadiqna,項目名稱:TicketDesk,代碼行數:64,代碼來源:Startup.SimpleInjector.cs


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