I know how to tell Castle Windsor to resolve a reference from a factory’s method using XML, but can I do it programmatically via the Container.AddComponent() interface? If not is there any other way to do it from code?
EDIT: There seems to be some confusion so let me clarify, I am looking for a way to do the following in code:
<facilities> <facility id='factory.support' type='Castle.Facilities.FactorySupport.FactorySupportFacility, Castle.MicroKernel' /> </facilities> <components> <component id='CustomerRepositoryFactory' type='ConsoleApplication2.CustomerRepositoryFactory, ConsoleApplication2' /> <component id='CustomerRepository' service='ConsoleApplication2.ICustomerRepository, ConsoleApplication2' type='ConsoleApplication2.CustomerRepository, ConsoleApplication2' factoryId='CustomerRepositoryFactory' factoryCreate='Create' /> </components>
(from this codebetter article on factory support in windsor and spring.net)
Directly from the Unit Test FactorySupportTestCase (which are your friends):