using Microsoft.Extensions.Configuration; using NCC.ConfigurableOptions; using System; using System.ComponentModel.DataAnnotations; namespace NCC.Common.Extensions { /// /// Demo配置选项 /// public sealed class DemoSettingsOptions : IConfigurableOptions { /// /// 名称 /// [Required] public string AntisSoftName { get; set; } /// /// 允许Ips /// public string[] AllowIps { get; set; } /// /// Bool值 /// public bool? AllowDemoBool { get; set; } /// /// 过期时间 /// public int? SetPreflightMaxAge { get; set; } public void PostConfigure(DemoSettingsOptions options, IConfiguration configuration) { AntisSoftName ??= "App.AntisSoft"; AllowIps ??= Array.Empty(); AllowDemoBool ??= true; } } }