У меня есть конфиг в appsettings.json, например:
"ClientId": {
"US": {
"xxxxxxxx": [ "xxxxxxxx" ]
},
"UK": {
"xxxxxxxx": [ "xxxxxxxx" ]
},
"PK": {
"xxxxxxxx": [ "xxxxxxxx" ]
},
"DK": {
"xxxxxxxx": [ "xxxxxxxx" ]
},
"IN": {
"xxxxxxxx": [ "xxxxxxxx" ]
},
"LV": {
"xxxxxxxx": [ "xxxxxxxx" ]
},
"EE": {
"xxxxxxxx": [ "xxxxxxxx" ]
}
}
Теперь я хочу отобразить этот раздел в словарь, например:
public class ClientIds
{
public Dictionary<string, List<string>> US { get; set; }
public Dictionary<string, List<string>> UK { get; set; }
public Dictionary<string, List<string>> PK { get; set; }
public Dictionary<string, List<string>> DK { get; set; }
public Dictionary<string, List<string>> IN { get; set; }
public Dictionary<string, List<string>> LV { get; set; }
public Dictionary<string, List<string>> EE { get; set; }
}
Но я получаю нулевое значение каждый раз,Вот мой начальный конфигурационный файл:
services.Configure<ClientIds>((settings) =>
{
Configuration.GetSection("ClientId").Bind(settings);
});
, а вот мой сервисный впрыск:
private readonly ClientIds _clientIds;
public MyService(IOptions<ClientIds> clientIds)
{
_clientIds = clientIds.Value;
}
Что здесь не так?