S8EffectiveRule.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using Admin.NET.Plugin.AiDOP.Entity.S8;
  2. using Admin.NET.Plugin.AiDOP.Service.S8.Rules.Definitions;
  3. namespace Admin.NET.Plugin.AiDOP.Service.S8.Rules;
  4. /// <summary>
  5. /// S8-RULE-GOVERNANCE-BATCH1:一条规则在本次执行中的**生效形态**
  6. /// —— 代码定义 + 租户运行参数 + 数据库行三者合一。
  7. ///
  8. /// <para>存在的理由是让「语义来自哪里」在类型上就不可混淆:
  9. /// evaluator 拿到的是 <see cref="Definition"/> 与 <see cref="Parameters"/>,
  10. /// <see cref="Row"/> 只用于 Id / RuleCode / 归属列这类**非语义**用途。
  11. /// 谁要是想从 <c>Row.RuleType</c> 取判定类型,一眼就能在 review 里看出来。</para>
  12. /// </summary>
  13. public sealed class S8EffectiveRule
  14. {
  15. public S8EffectiveRule(AdoS8WatchRule row, S8RuleDefinition definition, S8RuleRuntimeParameters parameters)
  16. {
  17. Row = row;
  18. Definition = definition;
  19. Parameters = parameters;
  20. }
  21. /// <summary>数据库行。仅提供 Id / RuleCode / TenantId / FactoryId 等非语义信息。</summary>
  22. public AdoS8WatchRule Row { get; }
  23. /// <summary>代码定义。业务语义的**唯一**真源。</summary>
  24. public S8RuleDefinition Definition { get; }
  25. /// <summary>租户运行参数。</summary>
  26. public S8RuleRuntimeParameters Parameters { get; }
  27. /// <summary>按行 + 定义解析生效形态。</summary>
  28. public static S8EffectiveRule Resolve(AdoS8WatchRule row, S8RuleDefinition definition) =>
  29. new(row, definition, S8RuleRuntimeParameters.Resolve(row, definition));
  30. }