【问题标题】:Parameters to constructor in autofacautofac中构造函数的参数
【发布时间】:2013-07-04 13:44:17
【问题描述】:

我必须在屏幕 1 和 2 上显示网格视图

builder.RegisterInstance(dataGridView1)
builder.RegisterInstance(dataGridView2)
builder.RegisterType<GeneralHtmlNotifier>().As<INotifier>();

如果注册一个实例,我如何在类中告诉我想要命名 datagridview1 而不是 datagridview2 的构造函数

public GeneralHtmlNotifier(DataGridView dataGridView1, IEnumerable<IChecker> checkers)
{
    _clsDataGridView = dataGridView1;
    _checkers = checkers;
}

【问题讨论】:

  • 嗯......标题部分带有“autofac”很有趣!

标签: c# autofac


【解决方案1】:

像这样?

builder.RegisterInstance(new GeneralHtmlNotifier(dataGridView1, checkers));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-07-01
    • 2021-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-01
    • 1970-01-01
    相关资源
    最近更新 更多