I have the following configuration
"Options": {
"Host": "123",
"UserName": "test",
"Password": "test",
"Files": [
{
"Key": "asd",
"Value": {
"HostLocation": "asd",
"RemoteLocation": "asd"
}
}
]
}
And I'm trying to bind it to the following object
public class Options
{
public string Host { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public Dictionary<string, FileOptions> Files { get; set; }
public class FileOptions
{
public string HostLocation { get; set; }
public string RemoteLocation { get; set; }
}
}
The issue is when I'm trying to bind the the Files to the dictionary. They don't get bound. I get a key generated with the value of 1, and the value FileOptions are generated all with default string value.
This is my configuration mapping.
_serviceCollection.Configure<SftpOptions>(_configuration.GetSection("Options"));
What is wrong and how can I map the setting into the Options class.