GeWuYou 9ae0f63324 feat(setting): 添加设置事件系统和改进设置模型接口
- 新增 SettingsAllLoadedEvent 事件类,用于表示所有设置加载完成
- 新增 SettingsAppliedEvent 事件类,用于表示设置应用完成状态
- 新增 SettingsApplyingEvent 事件类,用于表示设置正在应用过程
- 新增 SettingsBatchChangedEvent 事件类,用于表示批量设置变更
- 新增 SettingsBatchSavedEvent 事件类,用于表示批量设置保存
- 新增 SettingsChangedEvent 通用设置变更事件类
- 新增 SettingsLoadedEvent 和 SettingsSavedEvent 事件类
- 在 SettingsModel 中添加对 GFramework.Core.extensions 的引用
- 更新 RegisterApplicator 方法支持链式调用并改进注释说明
- 新增 ISettingsChangedEvent 接口定义设置变更事件基础结构
- 修改 ISettingsModel 接口使 RegisterApplicator 方法支持链式调用
- 修改 ISettingsPersistence 接口继承 IContextUtility 接口
2026-01-17 13:16:50 +08:00

47 lines
2.0 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 System;
using System.Collections.Generic;
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, ISettingsData, 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<ISettingsSection> All();
/// <summary>
/// 注册可应用设置(必须手动注册)
/// </summary>
/// <typeparam name="T">可应用设置的类型必须继承自class和IApplyAbleSettings</typeparam>
/// <param name="applicator">要注册的可应用设置实例</param>
/// <returns>返回当前设置模型实例,支持链式调用</returns>
ISettingsModel RegisterApplicator<T>(T applicator) where T : class, IApplyAbleSettings;
}