我知道如何告诉 Castle Windsor 使用 XML 解析来自工厂方法的引用,但我可以通过 Container.AddComponent() 接口以编程方式完成吗?如果没有,还有其他方法可以从代码中做到这一点吗?
编辑: 似乎有些混乱,所以让我澄清一下,我正在寻找一种在代码中执行以下操作的方法:
<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>