You can register an instance as the implementation of a given component like this:
container.Register(Component
.For<ISomeDependency>()
.Instance(someDependencyInstance));
This means that everytime you resolve anything and ISomeDependency is part of the resolved object graph, the someDependencyInstance
instance will be used.
It that what you want, or did I misunderstand the question?
Based on additional information, here's a new attempt at answering the question.
You should be able to use container hierarchies for this. If a Windsor container can't resolve a type, it'll ask its parent. This means that you can create a child container that contains only the override and then ask that container to resolve the type for you.
Here's an example:
var container = new WindsorContainer();
container.Register(Component
.For<ISomeDependency>()
.ImplementedBy<SomeDependency>());
container.Register(Component
.For<IService>()
.ImplementedBy<Service>());
var childContainer = new WindsorContainer();
childContainer.Register(Component
.For<ISomeDependency>()
.ImplementedBy<SomeOtherDependency>());
childContainer.Parent = container;
var service = childContainer.Resolve<IService>();
The resolved service
will contain an instance of SomeOtherDependency and not SomeDependency.
Notice how childContainer
only overrides the registration of ISomeDependency. All other registrations are used from the parent.