I have a project in which my business layer is built using DI, but I'm trying to take an extra step and use Windsor to control the construction of the object.
Say I have an existing data layer (which I donβt want to change) that can be accessed through the following interface:
interface IDataFactory { IDataService Service { get; } }
A number of classes in my business layer depend on services open through IDataFactory:
IFactory factory = DataFactory.NewFactory(); IBusinessService service = new ConcreteBusinessService(factory.Service);
I understand that to register an IBusinessService in a Castle Windsor container, I would use code similar to this:
IWindsorContainer container = new WindsorContainer(); container.AddComponent("businessService", typeof(IBusinessService), typeof(ConcreteBusinessService));
But for life, I can't figure out how to register services from my data layer using my existing factory object. In essence, I would like to say:
container.AddComponent("dataService", typeof(IDataService), factory.service);
The Windsor seems to want me to say container.AddComponent ("dataService", typeof (IDataService), typeOf (SomeConcreteDataService) ), but in this case ConcreteDataService is internal to this assembly and therefore not available in mine.
How can I connect to the data service, given that SomeConcreteDataService is not known to my assembly?
This question is very similar to my own, with the exception of my case, AddComponent ("calculator", typeof (ICalcService), typeof (CalculatorService), "Create"); the call will not work - CalculatorService will be internal to another assembly, inaccessible to the assembly connecting the container.