mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
- 将Architecture类重构为使用构造函数注入IArchitectureConfiguration、IArchitectureServices和IArchitectureContext - 移除泛型参数和单例模式,改为使用依赖注入容器管理实例 - 添加异步初始化方法InitializeAsync支持异步初始化场景 - 引入ArchitectureOptions类统一管理架构配置选项 - 创建DefaultArchitectureConfiguration和DefaultArchitectureServices默认实现 - 新增IArchitectureContext接口提供统一的上下文访问 - 添加IAsyncInitializable接口支持异步初始化能力 - 简化架构生命周期阶段,移除Created、BeforeInit和AfterInit阶段 - 更新事件系统为ITypeEventSystem接口实现 - 重构命令和控制器接口,统一使用IContextAware替代多个能力接口 - 移除FunctionalArchitectureOptions和相关委托配置方式 - 优化日志记录使用配置中的LoggerFactory实例
88 lines
2.3 KiB
C#
88 lines
2.3 KiB
C#
|
|
using System.ComponentModel;
|
|
using GFramework.Core.command;
|
|
using GFramework.Core.events;
|
|
using GFramework.Core.ioc;
|
|
using GFramework.Core.logging;
|
|
using GFramework.Core.model;
|
|
using GFramework.Core.query;
|
|
using GFramework.Core.system;
|
|
using GFramework.Core.utility;
|
|
|
|
namespace GFramework.Core.architecture;
|
|
|
|
public class DefaultArchitectureContext(
|
|
IIocContainer container,
|
|
ITypeEventSystem typeEventSystem,
|
|
ILogger logger)
|
|
: IArchitectureContext
|
|
{
|
|
private readonly ITypeEventSystem _typeEventSystem = typeEventSystem;
|
|
public ILogger Logger { get; } = logger;
|
|
|
|
#region Component Retrieval
|
|
|
|
/// <summary>
|
|
/// 从IOC容器中获取指定类型的系统实例
|
|
/// </summary>
|
|
/// <typeparam name="TSystem">目标系统类型</typeparam>
|
|
/// <returns>对应的系统实例</returns>
|
|
public TSystem? GetSystem<TSystem>() where TSystem : class, ISystem
|
|
{
|
|
return container.Get<TSystem>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 从IOC容器中获取指定类型的模型实例
|
|
/// </summary>
|
|
/// <typeparam name="TModel">目标模型类型</typeparam>
|
|
/// <returns>对应的模型实例</returns>
|
|
public TModel? GetModel<TModel>() where TModel : class, IModel
|
|
{
|
|
return container.Get<TModel>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 从IOC容器中获取指定类型的工具实例
|
|
/// </summary>
|
|
/// <typeparam name="TUtility">目标工具类型</typeparam>
|
|
/// <returns>对应的工具实例</returns>
|
|
public TUtility? GetUtility<TUtility>() where TUtility : class, IUtility
|
|
{
|
|
return container.Get<TUtility>();
|
|
}
|
|
|
|
#endregion
|
|
|
|
public void SendCommand(ICommand command)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public TResult SendCommand<TResult>(ICommand<TResult> command)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public TResult SendQuery<TResult>(IQuery<TResult> query)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public void SendEvent<TEvent>()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public void SendEvent<TEvent>(TEvent e)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public IUnRegister RegisterEvent<TEvent>(Action<TEvent> handler)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
|
|
} |