I'm using Ninject as IoC container in my project. I have following class:
public class SomeRepository:ISomeRepository
{
public SomeRepository(string someDatabaseConnectionString)
{
// some code here..
}
}
In my application settings file I have connection string named "someDatabase". By default the one should add following configuration in order to inject this connection string into the constructor:
kernel.Bind<ISomeRepository>()
.To<SomeRepository>()
.WithConstructorArgument("someDatabaseConnectionString", connString);
But i want to implement conventional based binding of such strings. Values for all constructor parameters of string type that names ends with "ConnectionString" should be taken from application's connectionStrings configuration section and injected automatically. I want to implement similar convention for appSettings section as well. This approach described in greater details in Mark Seeman's "Primitive Dependencies" article ("Conventions for primitives" section). Castle Windsor container was used in examples.
Is it possible to implement such conventions using Ninject and what is the best way to do this? I have already tried ninject.extensions.conventions but seems it doesn't has such a functionality, does it?