GeWuYou af583c101c refactor(core): 重构协程扩展和函数式编程相关代码
- 优化 CommandCoroutineExtensions 中的代码格式和异常处理逻辑
- 简化 WaitForEvent 和 WaitForEventWithTimeout 中的EventData属性实现
- 调整 EventListenerScope 中的EventData属性访问器
- 重构 ControlExtensions 中 TakeIf 和 TakeUnless 方法的实现
- 优化 FunctionExtensions 中 Repeat 和 Partial 方法的代码结构
- 调整 PipeExtensions 和其他扩展类的文档注释格式
- 修改测试代码中的协程迭代和事件注册相关实现
- 优化 DataRepository 中的异步操作实现方式
= [release ci]
2026-02-01 14:07:59 +08:00

104 lines
3.2 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.model;
namespace GFramework.Game.Abstractions.setting;
/// <summary>
/// 设置模型接口:
/// - 管理 Settings Data 的生命周期
/// - 管理并编排 Settings Applicator
/// - 管理 Settings Migration
/// </summary>
public interface ISettingsModel : IModel
{
// =========================
// Data
// =========================
/// <summary>
/// 获取指定类型的设置数据(唯一实例)
/// </summary>
/// <typeparam name="T">设置数据类型必须继承自ISettingsData并具有无参构造函数</typeparam>
/// <returns>指定类型的设置数据实例</returns>
T GetData<T>() where T : class, ISettingsData, new();
/// <summary>
/// 获取所有已创建的设置数据
/// </summary>
/// <returns>所有已创建的设置数据集合</returns>
IEnumerable<ISettingsData> AllData();
// =========================
// Applicator
// =========================
/// <summary>
/// 注册设置应用器
/// </summary>
/// <typeparam name="T">设置数据类型必须实现IResetApplyAbleSettings接口且具有无参构造函数</typeparam>
/// <param name="applicator">要注册的设置应用器</param>
/// <returns>当前设置模型实例,支持链式调用</returns>
ISettingsModel RegisterApplicator<T>(T applicator) where T : class, IResetApplyAbleSettings;
/// <summary>
/// 获取指定类型的设置应用器
/// </summary>
/// <typeparam name="T">要获取的设置应用器类型必须继承自IResetApplyAbleSettings</typeparam>
/// <returns>设置应用器实例如果不存在则返回null</returns>
T? GetApplicator<T>() where T : class, IResetApplyAbleSettings;
/// <summary>
/// 获取所有设置应用器
/// </summary>
/// <returns>所有设置应用器的集合</returns>
IEnumerable<IResetApplyAbleSettings> AllApplicators();
// =========================
// Migration
// =========================
/// <summary>
/// 注册设置迁移器
/// </summary>
/// <param name="migration">要注册的设置迁移器</param>
/// <returns>当前设置模型实例,支持链式调用</returns>
ISettingsModel RegisterMigration(ISettingsMigration migration);
// =========================
// Lifecycle
// =========================
/// <summary>
/// 初始化所有设置数据(加载 + 迁移)
/// </summary>
/// <returns>异步操作任务</returns>
Task InitializeAsync();
/// <summary>
/// 保存所有设置数据
/// </summary>
/// <returns>异步操作任务</returns>
Task SaveAllAsync();
/// <summary>
/// 应用所有设置
/// </summary>
/// <returns>异步操作任务</returns>
Task ApplyAllAsync();
/// <summary>
/// 重置指定类型的设置
/// </summary>
/// <typeparam name="T">要重置的设置类型必须实现IResettable接口并具有无参构造函数</typeparam>
void Reset<T>() where T : class, ISettingsData, new();
/// <summary>
/// 重置所有设置数据与应用器
/// </summary>
void ResetAll();
}