本文整理汇总了C#中IWindsorContainer.BeginScope方法的典型用法代码示例。如果您正苦于以下问题:C# IWindsorContainer.BeginScope方法的具体用法?C# IWindsorContainer.BeginScope怎么用?C# IWindsorContainer.BeginScope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWindsorContainer
的用法示例。
在下文中一共展示了IWindsorContainer.BeginScope方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WindsorDependencyScope
/// <summary>
/// </summary>
/// <param name="container">Windsor container.</param>
public WindsorDependencyScope([NotNull] IWindsorContainer container)
{
if (container == null) throw new ArgumentNullException(nameof(container));
this.container = container;
this.scope = container.BeginScope();
}
示例2: Install
public void Install(IWindsorContainer container, IConfigurationStore store)
{
// webAPI
GlobalConfiguration.Configuration.Services.Replace(
typeof(System.Web.Http.Dispatcher.IHttpControllerActivator),
new Code.WindsorHttpControllerActivator(container));
// MVC
DependencyResolver.SetResolver(new Code.WindsorDependencyResolver(container));
container.Register(Component.For<IControllerFactory>().Instance(new Code.WindsorControllerFactory(container)));
// all classes
container.Register(Classes.FromThisAssembly().Pick().LifestyleTransient());
// scope
container.Register(Component.For<IDisposable>().Named(ScopeComponentName)
.UsingFactoryMethod((f, c) => container.BeginScope()).LifestylePerWebRequest());
// security - user manager
container.Register(Component.For<UserManager<ApplicationUser>>().LifestylePerWebRequest());
// security - identity user store
container.Register(Component.For<IUserStore<ApplicationUser>>().ImplementedBy<UserStore<ApplicationUser>>()
.DependsOn(ServiceOverride.ForKey<DbContext>().Eq("UserStoreContext"))
.LifestylePerWebRequest());
// security - identity user store context
container.Register(Component.For<DbContext>().Named("UserStoreContext").ImplementedBy<ApplicationDbContext>()
.LifestylePerWebRequest());
}
示例3: WindsorDependencyScope
public WindsorDependencyScope(IWindsorContainer container)
{
if (container == null)
{
throw new ArgumentNullException("container");
}
_container = container;
_scope = container.BeginScope();
}
示例4: WindsorDependencyScope
public WindsorDependencyScope(IWindsorContainer container)
{
_container = container;
_scope = container.BeginScope();
}
示例5: BeginScope
private static Response BeginScope(NancyContext context, IWindsorContainer container)
{
context.Items["LifestyleScope"] = container.BeginScope();
return null;
}
示例6: WithSession
private static void WithSession(
IWindsorContainer container, Action<IDocumentSession> action)
{
using (container.BeginScope())
{
var session = container.Resolve<IDocumentSession>();
action.Invoke(session);
session.SaveChanges();
container.Release(session);
}
}
示例7: WithEventStore
private static void WithEventStore(IWindsorContainer container, Action<IDocumentSession, IEventStoreSession> action)
{
using (container.BeginScope())
{
var store = container.Resolve<IDocumentStore>();
var session = container.Resolve<IDocumentSession>();
var eventStore = container.Resolve<EventStore>();
var eventStoreSession = eventStore.OpenSession(store, session);
action.Invoke(session, eventStoreSession);
eventStoreSession.SaveChanges();
container.Release(session);
}
}
示例8: WindsorDependencyScope
/// <summary>Initializes a new instance of the <see cref="WindsorDependencyScope"/> class.</summary>
/// <param name="container">The container.</param>
public WindsorDependencyScope(IWindsorContainer container)
{
this.container = container;
this.scope = container.BeginScope();
}
示例9: WindsorDependencyScope
public WindsorDependencyScope(IWindsorContainer cont)
{
_cont = cont;
_scope = cont.BeginScope();
}