using System;
using System.Collections.Generic;
namespace Svrnty.CQRS.Configuration;
///
/// Configuration for CQRS services and endpoints.
/// Supports extension by third-party packages through generic configuration storage.
///
public class CqrsConfiguration
{
private readonly Dictionary _configurations = new();
private readonly List> _mappingCallbacks = new();
///
/// Sets a configuration object for a specific type
///
public void SetConfiguration(T config) where T : class
{
_configurations[typeof(T)] = config;
}
///
/// Gets a configuration object for a specific type
///
public T? GetConfiguration() where T : class
{
return _configurations.TryGetValue(typeof(T), out var config) ? config as T : null;
}
///
/// Checks if a configuration exists for a specific type
///
public bool HasConfiguration() where T : class
{
return _configurations.ContainsKey(typeof(T));
}
///
/// Registers a callback to be executed during endpoint mapping.
/// Used by extension packages to register their endpoint mapping logic.
///
/// Callback that accepts an application builder (typically WebApplication)
public void AddMappingCallback(Action