我想用list参数注册一个对象,但不使用配置文件。这是我目前使用的配置文件:
<?xml version="1.0" encoding="utf-8" ?>
<castle>
<components>
<component id="EmailParser"
service="ESImportCommon.Email.IEmailParser, ESImportCommon"
type="ESImportCommon.Email.EmailParser, ESImportCommon">
</component>
</components>
</castle>
你可以这样做:
using ESImportCommon.Email;
....
var container = new WindsorContainer(new XmlInterpreter());
container.AddFacility<FactorySupportFacility>();
container.Register(Component.For<IEmailParser>().ImplementedBy<EmailParser>());
请注意,如果您不希望在web / app.config中进行任何配置,则无需将XmlInterpreter
实例传递给构造函数。