//
// 此文件由源生成器注入到用户项目中
namespace Apq.Cfg;
///
/// 标记一个类为配置节,源生成器将为其生成零反射的绑定代码
///
///
/// 使用示例:
///
/// [CfgSection("Database")]
/// public partial class DatabaseConfig
/// {
/// public string ConnectionString { get; set; }
/// public int Timeout { get; set; } = 30;
/// }
///
/// // 使用生成的绑定方法
/// var config = DatabaseConfig.BindFrom(cfg.GetSection("Database"));
///
///
[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public sealed class CfgSectionAttribute : System.Attribute
{
///
/// 配置节路径,如 "Database" 或 "App:Settings"
///
public string SectionPath { get; }
///
/// 是否生成扩展方法,默认为 true
///
public bool GenerateExtension { get; set; } = true;
///
/// 创建配置节特性
///
/// 配置节路径,为空时使用类名(去掉 Config/Settings 后缀)
public CfgSectionAttribute(string sectionPath = "")
{
SectionPath = sectionPath;
}
}