开发者

How do i use WindsorInstaller across multiple assemblies for registration

I am using Castle Windsor to handle my Dependency Injection and it has been working great up until now.

However, i am now trying to extend my project and add some additional libraries - im now struggling to figure the best way to leverage Castle.

I currently have the following assemblies

MyProject.Interfaces (contains IDBContext interface) MyProject.BusinessLogic (contains the Castle Windsor implementation) MyProject.DataAccess (contains implementation of I开发者_运维百科DBContext)

I currently have an installer called DBContextInstaller and it simply implements the following:

public void Install(IWindsorContainer container, IConfigurationStore store)
{
    container.Register(AllTypes.FromThisAssembly()
                .BasedOn<IDBContext>()
                .WithService
                .DefaultInterface()
                .Configure(reg => reg.LifeStyle.PerWebRequest));
}

I now have a new Assembly in this project - lets call it MyProject.UserService and it happens to have a new concrete implementation of IDBContext.

So my question - how can i change my Container.Register statement to have it inspect multiple libraries. NOTE i totally expect to have more and more libraries added to this scenario in the future. I would love for this installer to just find all implementations.

TIA


You could use AllTypes.FromAssemblyInDirectory...

container.Register(AllTypes.FromAssemblyInDirectory(new AssemblyFilter(folderPath)));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜