我正在按照在线教程学习 Castle.windsor。这是简单的示例代码:
public class Form1 {
private readonly HttpServiceWatcher serviceWatcher;
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
public Form1(HttpServiceWatcher serviceWatcher) : this()
{
this.serviceWatcher = serviceWatcher;
}
}
HttpServiceWatcher 在 xml 配置文件中。我的问题是:谁在调用具有参数的构造函数:public Form1(Http....)
?在 program.cs 我有这个:
container.AddComponent("form.component",typeof(Form1));
Form1 form1 = (Form1) container["form.component"];
Application.Run(form1);