I'm trying to register several types that share the same interface ISetting
with Windsor container.
Clarification: ISetting
interface doesn't require any implementation. It's only purpose is to help locate setting types within the assembly. Otherwise these setting types are not related to each other in any way, shape or form.
Normally I would create these types one-by-one with code along these lines:
var settingsManager = new SettingsManager();
var applicationSettings = settingsManager.LoadSettings<ApplicationSettings>();
var emailSettings = settingsManager.LoadSettings<EmailSettings>();
But I would like to register these components by convention, so I don't have to do it manually.
So far I have following code in one of WindsorInstallers:
container.Register( Classes.FromAssemblyContaining<ISetting>()
.BasedOn<ISetting>()
...help...
);
Clarification: Setting will be used within the class as concrete type (see below)
public class Service2
{
private readonly EmailSettings _settings;
public Service2(EmailSettings settings)
{
_settings = settings;
}
public void Awesome()
{
Console.WriteLine(_settings.Value);
}
}
My Goal: Even though I could inject all setting types into container one-by-one, I'm looking for a solution where I could locate and register all types inheriting from ISetting
using one (maybe two) statements.