Files
DP44/docs/ai/DataPRO/DataPRO.Core/ServiceManager.md
2026-04-17 14:55:32 -04:00

2.1 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/DataPRO.Core/ServiceManager/IServicePublishedEvent.cs
DataPRO/DataPRO.Core/ServiceManager/ServicePublishedEvent.cs
DataPRO/DataPRO.Core/ServiceManager/ServiceManager.cs
2026-04-17T16:36:18.703341+00:00 zai-org/GLM-5-FP8 1 5cab21cff0e733cd

ServiceManager Module Documentation

1. Purpose

The ServiceManager module implements a service locator pattern, enabling decoupled component communication within the application. It allows components to publish implementations of singleton interfaces (services) that other components can retrieve without direct knowledge of the publisher. The module provides event-driven notification when services are published or unpublished, supporting reactive architectures where consumers need to respond to service availability changes.


2. Public Interface

ServiceManager (Static Class)

A static service locator that manages a registry of interface-to-implementation mappings.

Method Signature Description
Publish<T> void Publish<T>(T item) where T : class Publishes a service implementation under its interface type T. Throws ArgumentException if the type is already published.
Publish void Publish(object item, IEnumerable<Type> interfaceList, bool skipPublishedInterfaces) Publishes a single object under multiple interface types. If skipPublishedInterfaces is true, silently skips already-published interfaces; otherwise throws ArgumentException.
Exists<T> bool Exists<T>() where T : class Returns true if interface type T has been published; otherwise false.
Exists bool Exists(Type t) Non-generic overload. Returns true if the specified type has been published; otherwise false.
Get<T> T Get<T>() where T : class Retrieves the published service for interface type T. Throws ArgumentException if not published.
Clear<T> void Clear<T>() where T : class Unpublishes the service for interface type T. Silently does nothing if the type is not