This is what my service contructor looks like:
public Service(string path)
and I'm configuring unity like this:
IUnityContainer container = new UnityContainer();
container.RegisterType<IService, Service>();
which of course is not correct. The path parameter needs to be specified, and I would like this to be configurable from the AppSettings so in this case I would be able to set it during configuration.
How do I do this?
As I understand your question, you want to read the path from AppSetting and then configure your UnityContainer programatically.
This can be done like this:
// Get path from app.config via ConfigurationManager.AppSettings
var container = new UnityContainer();
container.RegisterType<IService, Service>(new InjectionConstructor(path));
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