GeWuYou 0b7c64fd99 feat(data): 添加数据仓库功能并重构设置系统接口
- 新增 DataRepository 类实现数据存储和读取功能
- 添加数据仓库配置选项类 DataRepositoryOptions
- 定义 IData 接口作为通用数据标记接口
- 实现数据加载、保存、删除等异步操作方法
- 添加数据事件系统包括加载、保存、删除等事件类型
- 将 ISettingsData 接口重命名为 IResettable 并更新相关实现
- 更新 SettingsModel 和 SettingsPersistence 使用新的接口
- 修改 SettingsBatchChangedEvent 和 SettingsBatchSavedEvent 使用 IResettable 类型
- 重构 AudioSettings、GraphicsSettings、LocalizationSettings 继承新接口
- 更新 IPersistentApplyAbleSettings 接口依赖为 IResettable
2026-01-28 20:08:34 +08:00

52 lines
2.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>
/// 定义设置模型的接口,提供获取特定类型设置节的功能
/// </summary>
public interface ISettingsModel : IModel
{
/// <summary>
/// 获取或创建数据设置(自动创建)
/// </summary>
/// <typeparam name="T">设置数据的类型必须继承自class、ISettingsData且具有无参构造函数</typeparam>
/// <returns>指定类型的设置数据实例</returns>
T GetData<T>() where T : class, IResettable, new();
/// <summary>
/// 尝试获取指定类型的设置节实例
/// </summary>
/// <param name="type">要获取的设置节类型</param>
/// <param name="section">输出参数如果成功则包含找到的设置节实例否则为null</param>
/// <returns>如果找到指定类型的设置节则返回true否则返回false</returns>
bool TryGet(Type type, out ISettingsSection section);
/// <summary>
/// 获取已注册的可应用设置
/// </summary>
/// <typeparam name="T">可应用设置的类型必须继承自class和IApplyAbleSettings</typeparam>
/// <returns>指定类型的可应用设置实例如果不存在则返回null</returns>
T? GetApplicator<T>() where T : class, IApplyAbleSettings;
/// <summary>
/// 获取所有设置数据的集合
/// </summary>
/// <returns>包含所有设置数据的可枚举集合</returns>
IEnumerable<IResettable> AllData();
/// <summary>
/// 获取所有可应用设置的集合
/// </summary>
/// <returns>包含所有可应用设置的可枚举集合</returns>
IEnumerable<IApplyAbleSettings> AllApplicators();
/// <summary>
/// 注册可应用设置(必须手动注册)
/// </summary>
/// <typeparam name="T">可应用设置的类型必须继承自class和IApplyAbleSettings</typeparam>
/// <param name="applicator">要注册的可应用设置实例</param>
/// <returns>返回当前设置模型实例,支持链式调用</returns>
ISettingsModel RegisterApplicator<T>(T applicator) where T : class, IApplyAbleSettings;
}