Skip to content

NotificationRule

NotificationRule is the immutable-by-construction definition of a single metadata-driven rule: which model member (or method) to evaluate, which operator to apply, and what output to produce. Its constructor is private, so NotificationRuleEngine and every caller can only build instances through its four static factory methods (OP-CIA-04), and NotificationRuleEngine.CalculateNotification mutates the public _id field when constructing an out-property child rule so it can share the parent's identity.

Purpose

  • Describe, as data, which model member or method a rule evaluates, which comparison operator applies, and what target/constant value participates in the comparison — resolved entirely by reflection at run time by BuildExpr.
  • Restrict rule construction to four static factories (PropertyRule, MethodRule, EvalRuleOutProperty, EvalRuleOutValue) so every rule is built through one of a small set of well-defined shapes (OP-CIA-04).
  • Carry the conditional-output metadata (OutProperty, OutPropertyTypeName, OutValue) that lets a bool rule resolve to a derived property or constant value (CIA-BR-005, CIA-BR-006).

Context

  • Namespace: SAIF.Services.ClaimInfoApi.Core
  • Assembly/package: SAIF.Services.ClaimInfoApi.Core.dll, packaged inside the SAIF.SAIFCode.Core NuGet package

Public members

Member Signature Purpose
_id public Guid _id = Guid.NewGuid() Public mutable field holding the rule's identity; initialized to a new Guid and reassigned by NotificationRuleEngine.CalculateNotification when copying a parent rule's identity onto an out-property child rule (CIA-BR-005).
Position public int Position { get; set; } Determines the rule's output key via Key; controls which notification result this rule's value overwrites or is overwritten by (CIA-BR-001, CIA-BR-007).
Name public string Name { get; set; } Caller-supplied descriptive label for the rule; not used in evaluation logic*.
MemberName public string MemberName { get; set; } Name of the model property or method that BuildExpr resolves by reflection to build the expression body (CIA-BR-009, CIA-BR-010).
OperatorName public string OperatorName { get; set; } Selects the comparison branch: null for a plain property read, an ExpressionType name for a binary comparison, or a method name on the property's type otherwise (CIA-BR-010 through CIA-BR-012).
TargetValue public string TargetValue { get; set; } String literal converted to the target member's type and used as the constant/argument in the compiled expression; the literal "null" is treated as a null value (CIA-BR-008).
TypeName public string TypeName { get; set; } Assembly-qualified type name resolved by Type.GetType to determine whether the rule evaluates as int, bool, or string (CIA-BR-002).
OutProperty public string OutProperty { get; set; } When set on a bool rule that evaluates true, names the model property whose value becomes the notification, evaluated via a recursive child PropertyRule (CIA-BR-005).
OutPropertyTypeName public string OutPropertyTypeName { get; set; } Type name for the child PropertyRule built from OutProperty (CIA-BR-005).
OutValue public string OutValue { get; set; } Constant string returned when a bool rule evaluates true and OutProperty is not set (CIA-BR-006).
Key public string Key { get; } Computed "{Position}" string used as the dictionary key for notification results (CIA-BR-001).
Id public Guid Id { get; } Read-only accessor exposing the current value of _id.
Type public Type Type { get; } Resolves TypeName to a runtime Type via Type.GetType, driving the evaluation-branch dispatch in NotificationRuleEngine (CIA-BR-002).
PropertyRule(position, typeName, name, propertyName) public static NotificationRule PropertyRule(int, string, string, string) Builds a plain property-read rule with no comparison operator (CIA-BR-010).
MethodRule(position, name, methodName, parameterValue) public static NotificationRule MethodRule(int, string, string, string) Builds a rule that invokes a public method on the model with TypeName fixed to System.Object, so it is always evaluated through the string branch (CIA-BR-009)*.
EvalRuleOutProperty(position, typeName, name, memberName, operatorName, evalProperty, outProperty, outPropertyTypeName) public static NotificationRule EvalRuleOutProperty(int, string, string, string, string, string, string, string) Builds a conditional rule that, when its comparison is true, resolves to another model property's value (CIA-BR-005).
EvalRuleOutValue(position, typeName, name, memberName, operatorName, evalProperty, outValue) public static NotificationRule EvalRuleOutValue(int, string, string, string, string, string, string) Builds a conditional rule that, when its comparison is true, resolves to a fixed constant value (CIA-BR-006).

Behavioral notes

  • The constructor is private; PropertyRule, MethodRule, EvalRuleOutProperty, and EvalRuleOutValue are the only public construction paths. Deserializers that require a public default constructor cannot materialize this type*.
  • _id is a public mutable field rather than a read-only backing value, which lets NotificationRuleEngine.CalculateNotification reassign it on a freshly built child rule so the child shares the parent's identity for CIA-BR-005.
  • MethodRule sets TypeName to "System.Object" unconditionally, so a method rule is always dispatched through the string evaluation branch regardless of the method's actual return type; a method that does not return string causes a compilation failure in Compile a rule into a delegate*.

Constraints and usage notes

  • All string properties (MemberName, OperatorName, TargetValue, TypeName, OutProperty, OutPropertyTypeName, OutValue) are resolved by reflection or Type.GetType at evaluation time; malformed values surface as runtime exceptions rather than construction-time errors.

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.

Sources

  • Services/SAIF.Services.ClaimInfoApi.Core/NotificationRule.cs