Is there a .NET IoC that prefers convention over configuration?

后端 未结 6 927
天涯浪人
天涯浪人 2021-02-04 17:03

Simply put, if you had to use a IoC/DI container, thats easy to deploy (not a big fan of using config/xml file for everything), stable, good documentation and supports .net, whi

6条回答
  •  时光取名叫无心
    2021-02-04 17:40

    Castle Windsor allows this through the Register calls. A simple scenario is, let's say you have a lot of Controllers which implement an IController interface:

    container.Register(AllTypes.FromAssembly(assemblyA).BasedOn(typeof(IController));
    

    You can simplify this further by creating an IService interface (no members) and adding it to the above. This way when you create a service, it's automatically registered.

提交回复
热议问题