I have values in my AppConfig like this...
<appSettings>
<add key="id" value="1234" />
</appSettings>
In the IAppConfig class I have...
public interface IAppConfig
{
string id{ get; }
}
[ConfigurationProperty("id")]
public string id
{
get
{
return (string)this["id"];
}
set
{
this["id"] = value;
}
}
In a startup class I have
using SimpleInjector;
public static Container Container;
public static void Start()
{
Container = new Container();
IAppConfig appConfig = (IAppConfig)ConfigurationManager.GetSection("appSettings");
Container.Register<IAppConfig, AppConfig>(Lifestyle.Singleton);
}
And I inject it into another class...
private readonly IAppConfig config;
public ClassName(IAppConfig config)
{
this.config = config;
}
However the id (and other values) come up as empty strings. This happens in the Getter. I am calling the Start method before trying to access them. What am I doing wrong?