Though the question seems a bit weird. I am still riddling around in a new project I happen to join.
That project intensively uses Windsor Castle IoC. Inspecting the container after initialization tells me that some implementations have been registered as LifeStyle.Transient
and others have LifeStyle.Singleton
amongst others. Their custom bootstrapping code searches assemblies and does convention based registration but mentions nothing about Lifestyle. So how comes the registered components differ in lifestyle?
Does Castle Windsor have some magic naming convention?
for example: The pair IFooManager
and FooManager
would become a singleton, while IFoo
and Foo
would get transient life style.... (just due to *Manager).
As comments asked for it, this is the core registration that is executed in a loop over all /somehow enumerated/ assemblies:
var assembly = Assembly.LoadFrom(fileName);
container.Register(Classes.FromAssembly(assembly).Pick()
.If(t => TypeIsInNamespaces(includeNamespaces, t) && GetInterfacesOfType(t, includeNamespaces).Any())
.WithService.Select((t, baseT) => GetInterfacesOfType(t, includeNamespaces)).Configure(c => c.Named(GetName(c.Implementation))));
IWindsorInstaller
. In that second scenario there would be a class in the assembly that registers dependencies and specifies lifestyles. Does the bootstrap code containInstall
? – Scott Hannen