From c918085ba98687bb5cb001de855feeb770255747 Mon Sep 17 00:00:00 2001 From: GeWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Wed, 28 Jan 2026 12:47:08 +0800 Subject: [PATCH] =?UTF-8?q?refactor(setting):=20=E7=A7=BB=E9=99=A4=20Setti?= =?UTF-8?q?ngsModel=20=E7=9A=84=20IDisposable=20=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 从 SettingsModel 类定义中移除 IDisposable 接口 - 删除 Dispose 方法及其相关实现逻辑 - 移除 _disposed 标记字段和相关的资源清理代码 - 简化类结构,不再需要手动管理资源释放 - 依赖垃圾回收器自动处理内存管理 --- GFramework.Game/setting/SettingsModel.cs | 28 +----------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/GFramework.Game/setting/SettingsModel.cs b/GFramework.Game/setting/SettingsModel.cs index 17fb299..055c2c2 100644 --- a/GFramework.Game/setting/SettingsModel.cs +++ b/GFramework.Game/setting/SettingsModel.cs @@ -12,7 +12,7 @@ namespace GFramework.Game.setting; /// /// 设置模型类,用于管理不同类型的应用程序设置部分 /// -public class SettingsModel : AbstractModel, ISettingsModel, IDisposable +public class SettingsModel : AbstractModel, ISettingsModel { private static readonly ILogger Log = LoggerFactoryResolver.Provider.CreateLogger(nameof(SettingsModel)); private readonly ConcurrentDictionary _applicators = new(); @@ -20,16 +20,8 @@ public class SettingsModel : AbstractModel, ISettingsModel, IDisposable private readonly ConcurrentDictionary _loadAsyncMethodCache = new(); private readonly ConcurrentDictionary> _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(); } - - protected virtual void Dispose(bool disposing) - { - if (_disposed) return; - if (disposing) - { - // 清理托管资源 - _dataSettings.Clear(); - _applicators.Clear(); - _migrations.Clear(); - _migrationCache.Clear(); - _loadAsyncMethodCache.Clear(); - } - - // 清理非托管资源(如果有) - - _disposed = true; - } } \ No newline at end of file