sorry if this has been asked before i've tried doing some google-ing and haven't found any matches so here goes....
I have a Castle Windsor container that I add my components to using the following method (where container is an instance of IWindsorContainer
)...
container.Register(AllTypes.FromAssemblyNamed("App.Infrastructure")
.Where(x => !x.IsAbstract && !x.IsInterface)
.WithService.DefaultInterface()
This works great, however I then want to register another DLL in the same fashion to resolve dependencies from that...
container.Register(AllTypes.FromAssemblyNamed("App.Client.Infrastructure")
.Where(x => !x.IsAbstract && !x.IsInterface)
.WithService.DefaultInterface()
Now is there anyway I can get Windsor to notify me if the same interface resolution is being added, ie: only have 1 implementer per interface (take the first if more than one exists).
Hope I have explained myself well enough. I am using Castle Windsor version: 2.5.1.0 and upgrading / changing version is not really an options.
Update:
I've resolved this by removing the duplicate registrations after they have been registered. After the registration is completed I then have a loop below...
var registeredServices = new Dictionary<Type, string>();
foreach (var node in container.Kernel.GraphNodes)
{
var cmp = ((Castle.Core.ComponentModel)node);
Type t = cmp.Service;
if (registeredServices.ContainsKey(t))
container.Kernel.RemoveComponent(cmp.Name);
else
registeredServices.Add(t, cmp.Implementation.FullName);
}