Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windsor-Castle: Register All Types in assembly using config file

in code i can do some thing like this:

container.Register(AllTypes.FromAssemblyNamed("AssemblyName"));

can i do the same thing using Configuration file "Windsor.Config"???

like image 234
Nour Avatar asked Nov 30 '22 10:11

Nour


2 Answers

Responding to your comment.

There's also a 3rd way (in Windsor 2.5, currently in beta 2 - final release is expected very soon).

You can have each of your modules reference Windsor, and each module have its own set of Installers.

Than you can use the new directory scanning capability to install components from all these assemblies:

// In your root assembly
var container = new WindsorContainer();
container.Install(   
   FromAssembly.This(),
   FromAssembly.InDirectory(new AssemblyFilter("Modules")),
   Configuration.FromAppConfig()
)

In addition if you have components following identical structure you can also register components from multiple assemblies in single installer. See more here.

container.Register(
   AllTypes.FromAssemblyInDirectory(new AssemblyFilter("Modules"))
      .Where(t=>t.Namespace.EndsWith(".Services"))
      .WithService.DefaultInterface()
);
like image 93
Krzysztof Kozmic Avatar answered Dec 05 '22 14:12

Krzysztof Kozmic


I am pretty sure that only with the fluent configuration API can you set up conventions for your application so that as you create new components you aren’t required to register them individually, as you example shows.

like image 28
heads5150 Avatar answered Dec 05 '22 13:12

heads5150