Hope this helps Firstly you will need to register the CollectionResolver. Secondly I suggest you either change the constructor of CacheOrderRepo to explicitly reference LocalOrderRepo or define a different abstraction (e.g. ILocalOrderRepo) for it.
public class CacheOrderRepo : IOrderRepository
private readonly IEnumerable<IOrderRepository> realTimeRepos;
private readonly LocalOrderRepo localRepo;
public CacheOrderRepo(IEnumerable<IOrderRepository> realTime, LocalOrderRepo localRepo)
this.realTimeRepos = realTime;
this.localRepo = localRepo;
var container = new WindsorContainer();
var service = container.Resolve<IOrderRepository>();
To fix this issue In my project I need to use simultaneously Castle.Windsor and Moq dlls. Windsor requires Castle.Core also to be referenced in the project. , Problem can be solved using assembly binding - App.config:
it fixes the issue Okay, I think I've found a possible solution, partly using the approach detailed here which shows how it is possible to register Func<>s with Windsor. First, I register a delegate (Func<>) that uses the container to resolve by name:-
wish of those help How much time it takes to resolve an object graph depends on a lot of factors, such as: The size of the object graph The registered lifestyles of components and the location of those lifestyles in the graph (obviously if the root object is a singleton, resolving is really fast) The amount of work you do in your constructors
seems to work fine Rather than returning a null reference (as you say in your comment), I'd instead return a null service implementation. In other words, an implementation that is a no-op or just a passthrough. This way the class consuming the service doesn't need to add in any logic that it really should not know anything about (i.e. whether or not the service is valid to use in a given situation). To do this, you can just use the UsingFactoryMethod functionality to make the decision of which service to return at runtime. Taking the first registration that you want to be conditional:
// The URL for this service can be configured during runtime.
// If it is null or empty it should not be resolved.
.UsingFactoryMethod((kernel, context) =>