We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
It's possible to use the factory as a dictionary adapter using the IInstanceProvider:
public class AppSettingProvider : IInstanceProvider { public object GetInstance(IInstanceResolver instanceResolver, MethodInfo methodInfo, object[] arguments) { string key = methodInfo.Name; if (key.StartsWith("get_")) { key = key.Substring(4); } return Convert.ChangeType(ConfigurationManager.AppSettings[key], methodInfo.ReturnType); } }
Then you could use:
Kernel.Bind<ISettings>().ToFactory(() => new AppSettingProvider());
To bind a ISettings interface that the auto-properties will be automagically filled by the ConfigurationManager.AppSettings.
Source