I have a Repository
that accepts a Provider
which requires a ProviderCredentials
object be passed into it. The ProviderCredentials
object is a class, but it's values are only known at run time because they live in the Web.config in the <applicationSettings />
section.
How can I take the values out of the Web.config, build the ProviderCredentials
object and inject it into the Provider
using Ninject? Not sure if it matters, but the Provider
and ProviderCredentials
classes live in a separate project than the MVC project in the same solution.
You may consider binding ProviderCredentials
by way of a factory method, forcing the kernel to resolve its reference using your own custom logic:
kernel.Bind<ProviderCredentials>()
.ToMethod(context =>
new ProviderCredentials(ConfigurationManager.AppSettings["Foo"])
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With