本文整理汇总了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));
}
示例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);
}
示例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);
}
}
示例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);
}
示例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;
}