How to register a new List<IChecker> to Actofac ContainerBuilder
-
var servers = new List {
//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>();
builder.RegisterInstance(servers).As>();
builder.Register(c => new ServerChecker(c.Resolve>(), c.Resolve>()));
return builder.Build();I have a problem with how I should register my "where server = new List {..} 'to the Container Builder. My List of iChecker passed as a parameter to a ServerChecker. So much have I been able to solve, but not the list itself but I must have outside. The usual list of servers is much greater.
-
var servers = new List {
//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>();
builder.RegisterInstance(servers).As>();
builder.Register(c => new ServerChecker(c.Resolve>(), c.Resolve>()));
return builder.Build();I have a problem with how I should register my "where server = new List {..} 'to the Container Builder. My List of iChecker passed as a parameter to a ServerChecker. So much have I been able to solve, but not the list itself but I must have outside. The usual list of servers is much greater.
You're most likely never going to get an answer about this here. It's unlikely, in the extreme, that anyone who has ever used that library will ever see your question here. You're best bet would be to contact the people that wrote the library you're using.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak