using Elsa.Sql.Client; namespace Elsa.Sql.Services; public class ClientStore { private readonly Dictionary clients = new(); /// /// Dictionary of registered clients and their type. /// public IReadOnlyDictionary Clients => clients; /// /// Registers the specified client type with the store. /// The client type must inherit from . /// /// /// The type of the client to be registered. The client must be a class that implements the interface. /// /// /// The name of the client to register. If not provided, the name defaults to nameof(TClient). /// This value is used as a key to identify the client in the store. /// /// /// Thrown when a client with the same name is already registered in the store. /// /// /// This method registers a client type to the store using a unique key. The key is either the provided or the default name derived from . /// public void Register(string? name) where TClient : class, ISqlClient { var key = string.IsNullOrEmpty(name) ? nameof(TClient) : name; if (clients.ContainsKey(key)) { throw new InvalidOperationException($"Client with key '{name}' is already registered."); } clients.Add(key, typeof(TClient)); } }