NotificationData Class
Assembly: CodeEffects.Rule.Repository.dll
Namespace: CodeEffects.Rule.Repository
Summary
Holds what the Rule Repository knows about something that happened, and hands it to your NotificationDelegate together with the NotificationAction that says what it was.
Syntax
public class NotificationData
You never create this class. The repository creates one for each notification and passes it to the method you assigned to the Notify property of the repository configuration.
One shape serves every kind of notification, and a member that does not apply to one is null. The notification of a rule version, such as a request for approval or a version made live, names the rule, the rule version and the source object. The notification of a source version names the source object and the source version only, so the rule members are null. The Message property is a readable English sentence for an application that only forwards text.
All properties have public setters, but changing a value has no effect on the repository.
Properties
AgentId
Type: System.String
Gets or sets the ID of the AI agent that acted for the user, or null when the user acted themselves.
AgentName
Type: System.String
Gets or sets the name of that agent, as your application gave it in CurrentAgentName, or null.
Message
Type: System.String
Gets or sets what happened, as one readable English sentence.
Reason
Type: System.String
Gets or sets why a request was declined, in the words of the person who declined it. It is null for every other notification, and when the person gave no reason.
ReplacedVersionId
Type: System.Nullable<System.Int32>
Gets or sets the ID of the version that was live before a version was made live: a rule version for the notification of a rule version, a source version for that of a source version. It is null when nothing was live before, and for notifications that are not about a version made live.
RuleId
Type: System.Nullable<System.Guid>
Gets or sets the ID of the rule involved, or null for the notification of a source version.
RuleName
Type: System.String
Gets or sets the name of the rule.
RuleVersionId
Type: System.Nullable<System.Int32>
Gets or sets the ID of the rule version involved, or null for the notification of a source version.
RuleVersionName
Type: System.String
Gets or sets the name of the rule version.
SourceId
Type: System.Nullable<System.Int32>
Gets or sets the ID of the source object involved.
SourceName
Type: System.String
Gets or sets the display name of the source object.
SourceVersionId
Type: System.Nullable<System.Int32>
Gets or sets the ID of the source version involved: the version itself for the notification of a source version, or the version that a rule version is written against.
Timestamp
Type: System.DateTime
Gets or sets when it happened, in UTC.
UserId
Type: System.String
Gets or sets the ID of the user who did it: the value of CurrentUserId of the request.
UserName
Type: System.String
Gets or sets the name of that user, as your application gave it in CurrentUserName.
UserType
Type: CodeEffects.Rule.Repository.Common.UserType
Gets or sets what that user is: a person, an AI agent acting on its own, or a service. The default is UserType.User.
Example
using CodeEffects.Rule.Repository;
using CodeEffects.Rule.Repository.Common;
static void Notify(NotificationAction action, NotificationData data)
{
if (action != NotificationAction.RuleVersionMadeLive) return;
string replaced = data.ReplacedVersionId.HasValue
? $", replacing version {data.ReplacedVersionId}"
: string.Empty;
Console.WriteLine($"{data.Timestamp:u} {data.UserName} made '{data.RuleName}' live{replaced}.");
}