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