Files
DP44/docs/ai/Common/DTS.Common.Core/EventManager.md
2026-04-17 14:55:32 -04:00

1.8 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
Common/DTS.Common.Core/EventManager/EventManager.cs
2026-04-17T16:08:08.426285+00:00 zai-org/GLM-5-FP8 1 1537aca27bc7a4d4

EventManager

Purpose

Implements a lightweight, in-process publish/subscribe event system that allows components to communicate without direct coupling. Publishers emit events by type, and subscribers register callbacks to receive specific event types, optionally with filtering predicates. The module also supports diagnostic listeners for monitoring event system activity.

Public Interface

SubscriberCallbackDelegate<in T> (delegate)

  • void SubscriberCallbackDelegate<in T>(T item) where T : class — Delegate signature for event listeners.

DiagnosticCallbackDelegate (delegate)

  • void DiagnosticCallbackDelegate(EventDiagnosticType eventType, Type t, object eventData, string listener) — Delegate signature for diagnostic event listeners.

EventManager (static class)

  • static void Publish<T>(T eventData) where T : class — Publishes an event to all subscribers of type T. If no subscribers exist for the type, returns immediately. For each subscriber, evaluates the EventFilter predicate (if present) before invoking the callback.

  • static void Subscribe<T>(SubscriberCallbackDelegate<T> listener) where T : class — Subscribes a callback to events of type T without filtering.

  • static void Subscribe<T>(SubscriberCallbackDelegate<T> listener, Predicate<T> eventFilter) where T : class — Subscribes a callback to events of type T with an optional filter predicate. If the filter returns false for a given event, the callback is not invoked.

  • static void UnSubscribe<T>(SubscriberCallbackDelegate<T> listener) where T : class — Removes a subscriber callback from the subscriber