I have an interface class:
public interface IStartUpTask
{
bool IsEnabled { get; }
void Configure();
}
I have multimple classes implementing the same interface
One of the classes looks like this:
public class Log4NetStartUpTask : IStartUpTask
{
public bool IsEnabled { get { return true; } }
public void Configure()
{
string log4netConfigFilePath = ConfigurationManager.AppSettings["log4netConfigFilePath"];
if (log4netConfigFilePath == null)
throw new Exception("log4netConfigFilePath configuration is missing");
if (File.Exists(log4netConfigFilePath) == false)
throw new Exception("Log4Net configuration file was not found");
log4net.Config.XmlConfigurator.Configure(
new System.IO.FileInfo(log4netConfigFilePath));
}
}
How can i tell Ninject that i want all the classes implementing the IStartUpTask
to bind to themself automatically?
I found an example using StructureMap which does this, but i don't know how to do it in Ninject.
Scan(x => {
x.AssemblyContainingType<IStartUpTask>();
x.AddAllTypesOf<IStartUpTask>();
x.WithDefaultConventions();
});