refactor(setting): 移除 SettingsModel 的 IDisposable 接口实现

- 从 SettingsModel 类定义中移除 IDisposable 接口
- 删除 Dispose 方法及其相关实现逻辑
- 移除 _disposed 标记字段和相关的资源清理代码
- 简化类结构,不再需要手动管理资源释放
- 依赖垃圾回收器自动处理内存管理
This commit is contained in:
GeWuYou 2026-01-28 12:47:08 +08:00
parent d250ee1d93
commit c918085ba9

View File

@ -12,7 +12,7 @@ namespace GFramework.Game.setting;
/// <summary>
/// 设置模型类,用于管理不同类型的应用程序设置部分
/// </summary>
public class SettingsModel : AbstractModel, ISettingsModel, IDisposable
public class SettingsModel : AbstractModel, ISettingsModel
{
private static readonly ILogger Log = LoggerFactoryResolver.Provider.CreateLogger(nameof(SettingsModel));
private readonly ConcurrentDictionary<Type, IApplyAbleSettings> _applicators = new();
@ -20,16 +20,8 @@ public class SettingsModel : AbstractModel, ISettingsModel, IDisposable
private readonly ConcurrentDictionary<Type, MethodInfo> _loadAsyncMethodCache = new();
private readonly ConcurrentDictionary<Type, Dictionary<int, ISettingsMigration>> _migrationCache = new();
private readonly ConcurrentDictionary<(Type type, int from), ISettingsMigration> _migrations = new();
private bool _disposed;
private ISettingsPersistence? _persistence;
public void Dispose()
{
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
// -----------------------------
// Data
// -----------------------------
@ -207,22 +199,4 @@ public class SettingsModel : AbstractModel, ISettingsModel, IDisposable
{
_persistence = this.GetUtility<ISettingsPersistence>();
}
protected virtual void Dispose(bool disposing)
{
if (_disposed) return;
if (disposing)
{
// 清理托管资源
_dataSettings.Clear();
_applicators.Clear();
_migrations.Clear();
_migrationCache.Clear();
_loadAsyncMethodCache.Clear();
}
// 清理非托管资源(如果有)
_disposed = true;
}
}