示例#1
0
        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());
        }
        /// <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();
        }
 public WindsorDependencyScope(IWindsorContainer container)
 {
     if (container == null)
     {
         throw new ArgumentNullException("container");
     }
     _container = container;
     _scope = container.BeginScope();
 }
 public WindsorDependencyScope(IWindsorContainer container)
 {
     _container = container;
     _scope = container.BeginScope();
 }
 private static Response BeginScope(NancyContext context, IWindsorContainer container)
 {
     context.Items["LifestyleScope"] = container.BeginScope();
     return null;
 }
示例#6
0
 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
0
 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
0
 private static void WithEventStore(IWindsorContainer container, Action<EventStore> action)
 {
     using (container.BeginScope())
     {
         var eventStore = container.Resolve<EventStore>();
         action.Invoke(eventStore);
     }
 }
 /// <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();
 }
 public WindsorDependencyScope(IWindsorContainer cont)
 {
     _cont = cont;
     _scope = cont.BeginScope();
 }
示例#11
0
 public WindsorServiceScope(IWindsorContainer container)
 {
     _scope          = container.BeginScope();
     Resolver        = container.Resolve <IIocResolver>();
     ServiceProvider = Resolver;
 }