GFramework/GFramework.Cqrs/CqrsRuntimeFactory.cs
GeWuYou 1973fb2a60 feat(ioc): 添加Microsoft DI容器适配器和CQRS运行时模块
- 移除过时的Cqrs抽象引用
- 添加MicrosoftDiContainer实现IIocContainer接口
- 提供线程安全的依赖注入容器功能
- 支持单例、瞬态、作用域生命周期管理
- 实现CQRS请求管道行为注册功能
- 添加CqrsRuntimeModule服务模块
- 提供CQRS运行时实现和处理器注册器
- 扩展IArchitectureContext接口支持CQRS契约
2026-04-16 07:32:17 +08:00

51 lines
2.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using GFramework.Core.Abstractions.Ioc;
using GFramework.Core.Abstractions.Logging;
using GFramework.Cqrs.Abstractions.Cqrs;
using GFramework.Cqrs.Internal;
namespace GFramework.Cqrs;
/// <summary>
/// 提供 CQRS runtime 默认实现的跨程序集创建入口。
/// </summary>
/// <remarks>
/// <see cref="GFramework.Core" /> 需要在不暴露内部实现细节的前提下接入默认 CQRS runtime
/// 因此通过该工厂返回抽象接口,而不是直接公开内部 dispatcher / registrar 类型。
/// </remarks>
public static class CqrsRuntimeFactory
{
/// <summary>
/// 创建默认 CQRS runtime 分发器。
/// </summary>
/// <param name="container">目标依赖注入容器。</param>
/// <param name="logger">用于 runtime 诊断的日志器。</param>
/// <returns>默认 CQRS runtime。</returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="container" /> 或 <paramref name="logger" /> 为 <see langword="null" />。
/// </exception>
public static ICqrsRuntime CreateRuntime(IIocContainer container, ILogger logger)
{
ArgumentNullException.ThrowIfNull(container);
ArgumentNullException.ThrowIfNull(logger);
return new CqrsDispatcher(container, logger);
}
/// <summary>
/// 创建默认 CQRS 处理器注册器。
/// </summary>
/// <param name="container">目标依赖注入容器。</param>
/// <param name="logger">用于注册阶段诊断的日志器。</param>
/// <returns>默认 CQRS handler registrar。</returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="container" /> 或 <paramref name="logger" /> 为 <see langword="null" />。
/// </exception>
public static ICqrsHandlerRegistrar CreateHandlerRegistrar(IIocContainer container, ILogger logger)
{
ArgumentNullException.ThrowIfNull(container);
ArgumentNullException.ThrowIfNull(logger);
return new DefaultCqrsHandlerRegistrar(container, logger);
}
}