Skip to content

Dependency Injection

edpollitt edited this page Dec 3, 2015 · 1 revision

AutoConfig does not cache generated config objects. When using a DI framework, the recommended pattern is to register your configuration interface to a constant (i.e. singleton) instance to avoid repeated parsing of the configuration file.

Example, using Ninject:

Bind<IExampleConfiguration>().ToConstant(AutoConfig.Map<IExampleConfiguration>());

Or, referencing Nerdle.AutoConfig.Ninject

Bind<IExampleConfiguration>().ToConfig().InSingletonScope();

Clone this wiki locally