Конфигурация:
Код: Выделить всё
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"Assets": {
"SiteId": 14,
"Version": "2.3.12",
"Email": "creator@sltech.no",
"Name": "Creator framework"
}
}
Код: Выделить всё
public class AssetsConfig
{
private readonly IConfiguration _config;
public AssetsConfig(IConfiguration _config)
{
_config = raw;
}
public int SiteId { get; set; }
public string Culture { get; set; }
public IConfiguration Config => _config;
public string Version { get; }
public string Email { get; }
public string Name { get; }
public string ReleaseDate { get; }
}
Код: Выделить всё
AssetsConfig cnf = new Assets.AssetsConfig(builder.Configuration);
builder.Configuration.Bind(AssetsStatics.ConfigSectionName, cnf);
_ = builder.Services
.AddOptions()
.Configure(builder.Configuration)
.AddSingleton(cnf);
Код: Выделить всё
{SL.Assets.AssetsConfig}
Config: Sections = 102
Culture: null
Email: null
Name: null
ReleaseDate: null
SiteId: 14
Version: null
_raw: Sections = 102
Есть идеи?
Как видите, свойство SiteId назначено правильно, а остальные нет.
Есть идеи?
п>
Подробнее здесь: https://stackoverflow.com/questions/785 ... on-startup
Мобильная версия