var servers = new List<IChecker> {
//Server1
new DatabaseSystem { ServerName = "ANTIVIRUS" },
new DatabaseSizes { ServerName = "ANTIVIRUS"},
new DiskBackup { ServerName = "ANTIVIRUS"},
new SqlServerEventLog { ServerName="ANTIVIRUS"},
new DiskSystem { ServerName="ANTIVIRUS"},
//Server1
new DatabaseSystem { ServerName="SEJKG-S-DB01" },
new DatabaseSizes { ServerName = "SEJKG-S-DB01"},
new DiskBackup { ServerName = "SEJKG-S-DB01"},
new SqlServerEventLog { ServerName="SEJKG-S-DB01"},
new DiskSystem { ServerName="SEJKG-S-DB01"},
};
var builder = new ContainerBuilder();
builder.RegisterInstance(notifiers).As<IList<INotifier>>();
builder.RegisterInstance(servers).As<IList<IChecker>>();
builder.Register(c => new ServerChecker(c.Resolve<IList<IChecker>>(), c.Resolve<IList<INotifier>>()));
return builder.Build();
我有一个问题,我应该如何将我的“where server = new List {..}”注册到 Container Builder。我的 iChecker 列表作为参数传递给 ServerChecker。我能解决的问题很多,但不是列表本身,但我必须在外面。通常的服务器列表要大得多。