AuditRule Class
Assembly: CodeEffects.Rule.Audit.dll
Namespace: CodeEffects.Rule.Audit
Summary
Describes one rule of an AuditRuleset: which rule it is, and which versions it runs.
Syntax
public class AuditRule
You never create this class. AuditRuleset.Rules lists one for every rule of the ruleset, and AuditRuleset.Rule(..) finds one by name or by ID. Use Id to tell the evaluator which rule to evaluate, and the other properties to log which rule and which versions your application runs. Every property is read-only.
Properties
Id
Type: System.String
Gets the ID of the rule, as its XML carries it. It is what Evaluator<TSource>.Evaluate(source, ruleId) takes.
IsCalled
Type: System.Boolean
Gets whether the query did not ask for this rule, and it is in the ruleset only because a rule that was asked for calls it. The ruleset holds it so the engine finds it. Evaluating a called rule on its own is recorded like any other evaluation.
IsEvaluationType
Type: System.Boolean
Gets true for an evaluation type rule and false for an execution type rule.
Name
Type: System.String
Gets the name of the rule.
RuleVersionId
Type: System.Int32
Gets the ID of the live version of the rule that the ruleset holds. Evaluations of the rule are recorded against this version.
RuleVersionName
Type: System.String
Gets the name of that version.
SourceAlias
Type: System.String
Gets the alias of the source object of the rule: its class name, unless it was given another.
SourceVersionId
Type: System.Int32
Gets the ID of the source version that the evaluations of the rule are recorded against: the live version of its source object at the time the ruleset was loaded.
Methods
ToString()
Returns: System.String - The name and the version ID of the rule.
public override string ToString()
Returns a string such as Approve large orders (version 118).
Example
using CodeEffects.Rule.Audit;
using CodeEffects.Rule.Common.Models;
AuditRuleset ruleset = audit.GetRules(RuleQuery.ByNames("Approve large orders"));
foreach (AuditRule rule in ruleset.Rules)
{
Console.WriteLine(rule.Name + ": version " + rule.RuleVersionId + " (" + rule.RuleVersionName + "), source "
+ rule.SourceAlias + ", called by another rule: " + rule.IsCalled);
}