mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 19:03:29 +08:00
- 在SettingsModel中添加事件相关依赖引用 - 在SettingsPersistence中实现设置加载、保存、删除的事件发送机制 - 添加SettingsDeletedEvent用于通知设置删除操作 - 添加SettingsResetEvent和SettingsResetAllEvent支持设置重置功能 - 在SettingsPersistence中新增ResetAsync和ResetAllAsync方法 - 修改TryApply方法为实例方法并添加设置应用过程的事件通知 - 添加SettingsApplyingEvent和SettingsAppliedEvent跟踪设置应用状态 - [skip ci]
52 lines
1.3 KiB
C#
52 lines
1.3 KiB
C#
using GFramework.Game.Abstractions.setting;
|
|
|
|
namespace GFramework.Game.setting.events;
|
|
|
|
/// <summary>
|
|
/// 表示设置重置事件
|
|
/// </summary>
|
|
/// <typeparam name="T">设置节类型</typeparam>
|
|
public class SettingsResetEvent<T> : ISettingsChangedEvent
|
|
where T : ISettingsSection
|
|
{
|
|
/// <summary>
|
|
/// 构造函数
|
|
/// </summary>
|
|
/// <param name="oldSettings">重置前的设置</param>
|
|
/// <param name="newSettings">重置后的新设置</param>
|
|
public SettingsResetEvent(T oldSettings, T newSettings)
|
|
{
|
|
OldSettings = oldSettings;
|
|
NewSettings = newSettings;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取重置前的设置
|
|
/// </summary>
|
|
public T OldSettings { get; }
|
|
|
|
/// <summary>
|
|
/// 获取重置后的新设置
|
|
/// </summary>
|
|
public T NewSettings { get; }
|
|
|
|
/// <summary>
|
|
/// 获取类型化的设置实例(返回新设置)
|
|
/// </summary>
|
|
public T TypedSettings => NewSettings;
|
|
|
|
/// <summary>
|
|
/// 获取设置类型
|
|
/// </summary>
|
|
public Type SettingsType => typeof(T);
|
|
|
|
/// <summary>
|
|
/// 获取设置实例
|
|
/// </summary>
|
|
public ISettingsSection Settings => NewSettings;
|
|
|
|
/// <summary>
|
|
/// 获取重置时间
|
|
/// </summary>
|
|
public DateTime ChangedAt { get; } = DateTime.UtcNow;
|
|
} |