谁调用构造函数witth参数(Castle.Windsor) [英] who calls the constructor witth parameter (Castle.Windsor)

查看:79
本文介绍了谁调用构造函数witth参数(Castle.Windsor)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在根据在线教程学习castle.windsor。这是简单的示例代码:

I am learning castle.windsor following the tutorial online. this is the simple sample code:

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 conf文件中。
我的问题是:谁在调用具有以下参数的构造函数: public Form1(Http ....)?在program.cs上的
我有这个:

HttpServiceWatcher is in the xml conf file. My question is: who is calling the constructor that has the parameter: public Form1(Http....) ? at the program.cs i have this:

container.AddComponent("form.component",typeof(Form1));

Form1 form1 = (Form1) container["form.component"];

Application.Run(form1);


推荐答案

容器在创建请求的对象时调用构造函数。被调用的构造函数是容器可以满足的具有最多参数的构造函数。

The container calls the constructor when it creates the requested object. The constructor that gets called is the constructor with the most arguments that the container can satisfy.

这篇关于谁调用构造函数witth参数(Castle.Windsor)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆