using System;
using GFramework.Core.Abstractions.command;
using GFramework.Core.Abstractions.events;
using GFramework.Core.Abstractions.logging;
using GFramework.Core.Abstractions.model;
using GFramework.Core.Abstractions.query;
using GFramework.Core.Abstractions.system;
using GFramework.Core.Abstractions.utility;
namespace GFramework.Core.Abstractions.architecture;
///
/// 架构上下文接口,提供对系统、模型、工具类的访问以及命令、查询、事件的发送和注册功能
///
public interface IArchitectureContext
{
///
/// 获取日志工厂
///
ILoggerFactory LoggerFactory { get; }
///
/// 获取指定类型的系统实例
///
/// 系统类型,必须继承自ISystem接口
/// 系统实例,如果不存在则返回null
TSystem? GetSystem() where TSystem : class, ISystem;
///
/// 获取指定类型的模型实例
///
/// 模型类型,必须继承自IModel接口
/// 模型实例,如果不存在则返回null
TModel? GetModel() where TModel : class, IModel;
///
/// 获取指定类型的工具类实例
///
/// 工具类类型,必须继承自IUtility接口
/// 工具类实例,如果不存在则返回null
TUtility? GetUtility() where TUtility : class, IUtility;
///
/// 发送一个命令
///
/// 要发送的命令
void SendCommand(ICommand command);
///
/// 发送一个带返回值的命令
///
/// 命令执行结果类型
/// 要发送的命令
/// 命令执行结果
TResult SendCommand(ICommand command);
///
/// 发送一个查询请求
///
/// 查询结果类型
/// 要发送的查询
/// 查询结果
TResult SendQuery(IQuery query);
///
/// 发送一个事件
///
/// 事件类型,必须具有无参构造函数
void SendEvent() where TEvent : new();
///
/// 发送一个带参数的事件
///
/// 事件类型
/// 事件参数
void SendEvent(TEvent e) where TEvent : class;
///
/// 注册事件处理器
///
/// 事件类型
/// 事件处理委托
/// 事件注销接口
IUnRegister RegisterEvent(Action handler);
///
/// 取消注册事件监听器
///
/// 事件类型
/// 要取消注册的事件回调方法
void UnRegisterEvent(Action onEvent);
}