mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 19:03:29 +08:00
- 调整了 Architecture 类中字段和方法的布局,提升可读性 - 优化了命令执行逻辑,明确区分有无返回值的命令处理 - 规范了接口和抽象类的注释格式,增强文档清晰度 - 统一了代码风格,对齐缩进与换行符使用 - 补充了事件系统中泛型事件类的功能实现 - 完善了 README 文档中的条目结构和内容表述
56 lines
1.9 KiB
C#
56 lines
1.9 KiB
C#
using GFramework.Core.model;
|
||
using GFramework.Core.system;
|
||
using GFramework.Core.utility;
|
||
|
||
namespace GFramework.Core.extensions;
|
||
|
||
/// <summary>
|
||
/// 提供获取模型对象扩展方法的静态类
|
||
/// </summary>
|
||
public static class CanGetModelExtension
|
||
{
|
||
/// <summary>
|
||
/// 从架构中获取指定类型的模型实例
|
||
/// </summary>
|
||
/// <typeparam name="T">要获取的模型类型,必须实现IModel接口</typeparam>
|
||
/// <param name="self">实现ICanGetModel接口的对象实例</param>
|
||
/// <returns>指定类型的模型实例</returns>
|
||
public static T GetModel<T>(this ICanGetModel self) where T : class, IModel
|
||
{
|
||
return self.GetArchitecture().GetModel<T>();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 提供获取系统对象扩展方法的静态类
|
||
/// </summary>
|
||
public static class CanGetSystemExtension
|
||
{
|
||
/// <summary>
|
||
/// 从架构中获取指定类型的系统实例
|
||
/// </summary>
|
||
/// <typeparam name="T">要获取的系统类型,必须实现ISystem接口</typeparam>
|
||
/// <param name="self">实现ICanGetSystem接口的对象实例</param>
|
||
/// <returns>指定类型的系统实例</returns>
|
||
public static T GetSystem<T>(this ICanGetSystem self) where T : class, ISystem
|
||
{
|
||
return self.GetArchitecture().GetSystem<T>();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 提供获取工具对象扩展方法的静态类
|
||
/// </summary>
|
||
public static class CanGetUtilityExtension
|
||
{
|
||
/// <summary>
|
||
/// 从架构中获取指定类型的工具实例
|
||
/// </summary>
|
||
/// <typeparam name="T">要获取的工具类型,必须实现IUtility接口</typeparam>
|
||
/// <param name="self">实现ICanGetUtility接口的对象实例</param>
|
||
/// <returns>指定类型的工具实例</returns>
|
||
public static T GetUtility<T>(this ICanGetUtility self) where T : class, IUtility
|
||
{
|
||
return self.GetArchitecture().GetUtility<T>();
|
||
}
|
||
} |