diff --git a/GFramework.Core.Abstractions/serializer/IRuntimeTypeSerializer.cs b/GFramework.Core.Abstractions/serializer/IRuntimeTypeSerializer.cs index 9545de7..44466e0 100644 --- a/GFramework.Core.Abstractions/serializer/IRuntimeTypeSerializer.cs +++ b/GFramework.Core.Abstractions/serializer/IRuntimeTypeSerializer.cs @@ -14,13 +14,13 @@ namespace GFramework.Core.Abstractions.serializer; /// -/// 运行时类型序列化器接口,继承自ISerializer接口 -/// 提供基于运行时类型的对象序列化和反序列化功能 +/// 运行时类型序列化器接口,继承自ISerializer接口 +/// 提供基于运行时类型的对象序列化和反序列化功能 /// public interface IRuntimeTypeSerializer : ISerializer { /// - /// 将指定对象序列化为字符串 + /// 将指定对象序列化为字符串 /// /// 要序列化的对象 /// 对象的运行时类型 @@ -28,7 +28,7 @@ public interface IRuntimeTypeSerializer : ISerializer string Serialize(object obj, Type type); /// - /// 将字符串数据反序列化为指定类型的对象 + /// 将字符串数据反序列化为指定类型的对象 /// /// 要反序列化的字符串数据 /// 目标对象的运行时类型 diff --git a/GFramework.Core.Abstractions/versioning/IVersioned.cs b/GFramework.Core.Abstractions/versioning/IVersioned.cs index ea39d70..a0d5ca3 100644 --- a/GFramework.Core.Abstractions/versioning/IVersioned.cs +++ b/GFramework.Core.Abstractions/versioning/IVersioned.cs @@ -14,12 +14,12 @@ namespace GFramework.Core.Abstractions.versioning; /// -/// 定义具有版本信息的接口 +/// 定义具有版本信息的接口 /// public interface IVersioned { /// - /// 获取对象的版本号 + /// 获取对象的版本号 /// int Version { get; } } \ No newline at end of file diff --git a/GFramework.Core.Tests/coroutine/CoroutineExtensionsTests.cs b/GFramework.Core.Tests/coroutine/CoroutineExtensionsTests.cs index 37f0895..e39866c 100644 --- a/GFramework.Core.Tests/coroutine/CoroutineExtensionsTests.cs +++ b/GFramework.Core.Tests/coroutine/CoroutineExtensionsTests.cs @@ -256,7 +256,7 @@ public class CoroutineExtensionsTests public void ParallelCoroutines_Should_Return_Valid_Coroutine() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); var coroutine1 = CreateSimpleCoroutine(); var coroutine2 = CreateSimpleCoroutine(); @@ -272,7 +272,7 @@ public class CoroutineExtensionsTests public void ParallelCoroutines_Should_Execute_Coroutines_In_Parallel() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); var executionCounts = new Dictionary { { 1, 0 }, { 2, 0 }, { 3, 0 } }; var coroutine1 = CreateDelayedCoroutine(() => executionCounts[1]++, 0.5); @@ -299,7 +299,7 @@ public class CoroutineExtensionsTests public void ParallelCoroutines_Should_Handle_Empty_Array() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); var parallel = scheduler.ParallelCoroutines(); @@ -313,7 +313,7 @@ public class CoroutineExtensionsTests public void ParallelCoroutines_Should_Handle_Null_Array() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); var parallel = scheduler.ParallelCoroutines(null); diff --git a/GFramework.Core.Tests/coroutine/WaitForAllCoroutinesTests.cs b/GFramework.Core.Tests/coroutine/WaitForAllCoroutinesTests.cs index e1bcf2d..3694aee 100644 --- a/GFramework.Core.Tests/coroutine/WaitForAllCoroutinesTests.cs +++ b/GFramework.Core.Tests/coroutine/WaitForAllCoroutinesTests.cs @@ -26,7 +26,7 @@ public class WaitForAllCoroutinesTests public void WaitForAllCoroutines_Should_Not_Be_Done_Initially_With_Running_Coroutines() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); var coroutine1 = CreateDelayedCoroutine(() => { }, 1.0); var coroutine2 = CreateDelayedCoroutine(() => { }, 1.0); @@ -48,7 +48,7 @@ public class WaitForAllCoroutinesTests public void WaitForAllCoroutines_Should_Be_Done_When_All_Coroutines_Complete() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); var coroutine1 = CreateSimpleCoroutine(); var coroutine2 = CreateSimpleCoroutine(); @@ -73,7 +73,7 @@ public class WaitForAllCoroutinesTests public void WaitForAllCoroutines_Should_Wait_For_All_Delayed_Coroutines() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); var executionCount = 0; var coroutine1 = CreateDelayedCoroutine(() => executionCount++, 1.0); @@ -105,7 +105,7 @@ public class WaitForAllCoroutinesTests public void WaitForAllCoroutines_Should_Handle_Empty_Handles_List() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); var handles = Array.Empty(); var wait = new WaitForAllCoroutines(scheduler, handles); @@ -120,7 +120,7 @@ public class WaitForAllCoroutinesTests public void WaitForAllCoroutines_Should_Throw_ArgumentNullException_When_Handles_Is_Null() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); Assert.Throws(() => new WaitForAllCoroutines(scheduler, null!)); } @@ -143,7 +143,7 @@ public class WaitForAllCoroutinesTests public void WaitForAllCoroutines_Should_Handle_Single_Coroutine() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); var coroutine = CreateSimpleCoroutine(); var handles = new List { scheduler.Run(coroutine) }; @@ -162,7 +162,7 @@ public class WaitForAllCoroutinesTests public void WaitForAllCoroutines_Should_Not_Be_Done_When_Some_Coroutines_Complete() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); var executionCount = 0; var coroutine1 = CreateSimpleCoroutine(); @@ -191,7 +191,7 @@ public class WaitForAllCoroutinesTests public void WaitForAllCoroutines_Should_Handle_Killed_Coroutines() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); var coroutine1 = CreateDelayedCoroutine(() => { }, 1.0); var coroutine2 = CreateDelayedCoroutine(() => { }, 1.0); @@ -222,7 +222,7 @@ public class WaitForAllCoroutinesTests public void WaitForAllCoroutines_Should_Handle_Paused_And_Resumed_Coroutines() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); var executionCount = 0; var coroutine1 = CreateDelayedCoroutine(() => executionCount++, 1.0); @@ -258,7 +258,7 @@ public class WaitForAllCoroutinesTests public void WaitForAllCoroutines_Update_Should_Not_Affect_State() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); var coroutine = CreateDelayedCoroutine(() => { }, 1.0); var handles = new List { scheduler.Run(coroutine) }; @@ -278,7 +278,7 @@ public class WaitForAllCoroutinesTests public void WaitForAllCoroutines_Should_Handle_Invalid_Handles() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); var handles = new List { default }; @@ -294,7 +294,7 @@ public class WaitForAllCoroutinesTests public void WaitForAllCoroutines_Should_Handle_Mixed_Valid_And_Invalid_Handles() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); var coroutine = CreateSimpleCoroutine(); var handles = new List @@ -317,7 +317,7 @@ public class WaitForAllCoroutinesTests public void WaitForAllCoroutines_Should_Handle_Many_Coroutines() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); var executionCount = 0; var handles = new List(); @@ -340,7 +340,7 @@ public class WaitForAllCoroutinesTests public void WaitForAllCoroutines_Should_Handle_Coroutines_With_Exceptions() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); var coroutine1 = CreateSimpleCoroutine(); var coroutine2 = CreateExceptionCoroutine(); @@ -367,7 +367,7 @@ public class WaitForAllCoroutinesTests public void WaitForAllCoroutines_Should_Work_With_ParallelCoroutines() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); var executionOrder = new List(); var coroutine1 = CreateDelayedCoroutine(() => executionOrder.Add(1), 0.5); @@ -397,7 +397,7 @@ public class WaitForAllCoroutinesTests public void WaitForAllCoroutines_Should_Implement_IYieldInstruction() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); var handles = Array.Empty(); var wait = new WaitForAllCoroutines(scheduler, handles); @@ -412,7 +412,7 @@ public class WaitForAllCoroutinesTests public void WaitForAllCoroutines_Should_Be_Done_Immediately_When_All_Coroutines_Complete_Immediately() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); var coroutine1 = CreateSimpleCoroutine(); var coroutine2 = CreateSimpleCoroutine(); @@ -438,7 +438,7 @@ public class WaitForAllCoroutinesTests public void WaitForAllCoroutines_Should_Handle_Duplicate_Handles() { var timeSource = new TestTimeSource(); - var scheduler = new CoroutineScheduler(timeSource, 1); + var scheduler = new CoroutineScheduler(timeSource); var coroutine = CreateDelayedCoroutine(() => { }, 1.0); var handle = scheduler.Run(coroutine); diff --git a/GFramework.Game.Abstractions/GlobalUsings.cs b/GFramework.Game.Abstractions/GlobalUsings.cs index deaf08d..3ca0d0f 100644 --- a/GFramework.Game.Abstractions/GlobalUsings.cs +++ b/GFramework.Game.Abstractions/GlobalUsings.cs @@ -19,14 +19,13 @@ global using System.Threading.Tasks; #if NETSTANDARD2_0 || NETFRAMEWORK || NETCOREAPP2_0 using System.ComponentModel; -namespace System.Runtime.CompilerServices +namespace System.Runtime.CompilerServices; + +/// +/// 用于标记仅初始化 setter 的特殊类型 +/// +[EditorBrowsable(EditorBrowsableState.Never)] +public static class IsExternalInit { - /// - /// 用于标记仅初始化 setter 的特殊类型 - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static class IsExternalInit - { - } } #endif \ No newline at end of file diff --git a/GFramework.Game.Abstractions/data/DataRepositoryOptions.cs b/GFramework.Game.Abstractions/data/DataRepositoryOptions.cs index b12cd48..5ae6b08 100644 --- a/GFramework.Game.Abstractions/data/DataRepositoryOptions.cs +++ b/GFramework.Game.Abstractions/data/DataRepositoryOptions.cs @@ -14,27 +14,27 @@ namespace GFramework.Game.Abstractions.data; /// -/// 数据仓库配置选项 +/// 数据仓库配置选项 /// public class DataRepositoryOptions { /// - /// 存储基础路径(如 "user://data/") + /// 存储基础路径(如 "user://data/") /// public string BasePath { get; set; } = ""; /// - /// 键名前缀(如 "Game",生成的键为 "Game_SettingsData") + /// 键名前缀(如 "Game",生成的键为 "Game_SettingsData") /// public string KeyPrefix { get; set; } = ""; /// - /// 是否在保存时自动备份 + /// 是否在保存时自动备份 /// public bool AutoBackup { get; set; } = false; /// - /// 是否启用加载/保存事件 + /// 是否启用加载/保存事件 /// public bool EnableEvents { get; set; } = true; } \ No newline at end of file diff --git a/GFramework.Game.Abstractions/data/IData.cs b/GFramework.Game.Abstractions/data/IData.cs index ac834a8..09f793c 100644 --- a/GFramework.Game.Abstractions/data/IData.cs +++ b/GFramework.Game.Abstractions/data/IData.cs @@ -14,6 +14,6 @@ namespace GFramework.Game.Abstractions.data; /// -/// 通用数据标记接口 +/// 通用数据标记接口 /// public interface IData; \ No newline at end of file diff --git a/GFramework.Game.Abstractions/data/IDataRepository.cs b/GFramework.Game.Abstractions/data/IDataRepository.cs index 0077a5b..79078b2 100644 --- a/GFramework.Game.Abstractions/data/IDataRepository.cs +++ b/GFramework.Game.Abstractions/data/IDataRepository.cs @@ -16,26 +16,26 @@ using GFramework.Core.Abstractions.utility; namespace GFramework.Game.Abstractions.data; /// -/// 定义数据仓库接口,提供异步的数据加载、保存、检查存在性和删除操作 +/// 定义数据仓库接口,提供异步的数据加载、保存、检查存在性和删除操作 /// public interface IDataRepository : IUtility { /// - /// 异步加载指定类型的数据对象 + /// 异步加载指定类型的数据对象 /// /// 要加载的数据类型,必须实现IData接口并具有无参构造函数 /// 返回加载的数据对象的Task Task LoadAsync() where T : class, IData, new(); /// - /// 根据类型异步加载数据 + /// 根据类型异步加载数据 /// /// 要加载的数据类型 /// 异步操作任务,返回实现IData接口的数据对象 Task LoadAsync(Type type); /// - /// 异步保存指定的数据对象 + /// 异步保存指定的数据对象 /// /// 要保存的数据类型,必须实现IData接口 /// 要保存的数据对象 @@ -43,21 +43,21 @@ public interface IDataRepository : IUtility Task SaveAsync(T data) where T : class, IData; /// - /// 异步检查指定类型的数据是否存在 + /// 异步检查指定类型的数据是否存在 /// /// 要检查的数据类型,必须实现IData接口 /// 返回表示数据是否存在布尔值的Task Task ExistsAsync() where T : class, IData; /// - /// 异步删除指定类型的数据 + /// 异步删除指定类型的数据 /// /// 要删除的数据类型,必须实现IData接口 /// 表示异步删除操作的Task Task DeleteAsync() where T : class, IData; /// - /// 批量保存多个数据 + /// 批量保存多个数据 /// /// 要保存的数据列表,实现IData接口的对象集合 /// 异步操作任务 diff --git a/GFramework.Game.Abstractions/data/events/DataBatchSavedEvent.cs b/GFramework.Game.Abstractions/data/events/DataBatchSavedEvent.cs index f45a295..75e3e34 100644 --- a/GFramework.Game.Abstractions/data/events/DataBatchSavedEvent.cs +++ b/GFramework.Game.Abstractions/data/events/DataBatchSavedEvent.cs @@ -14,7 +14,7 @@ namespace GFramework.Game.Abstractions.data.events; /// -/// 表示数据批次保存事件的记录类型 +/// 表示数据批次保存事件的记录类型 /// /// 包含已保存数据项的集合,实现了IData接口 public sealed record DataBatchSavedEvent(ICollection List); \ No newline at end of file diff --git a/GFramework.Game.Abstractions/data/events/DataDeletedEvent.cs b/GFramework.Game.Abstractions/data/events/DataDeletedEvent.cs index c05c3e0..a4dc90c 100644 --- a/GFramework.Game.Abstractions/data/events/DataDeletedEvent.cs +++ b/GFramework.Game.Abstractions/data/events/DataDeletedEvent.cs @@ -14,7 +14,7 @@ namespace GFramework.Game.Abstractions.data.events; /// -/// 表示数据删除事件的记录类型 +/// 表示数据删除事件的记录类型 /// /// 被删除数据的类型 public sealed record DataDeletedEvent(Type Type); \ No newline at end of file diff --git a/GFramework.Game.Abstractions/data/events/DataLoadedEvent.cs b/GFramework.Game.Abstractions/data/events/DataLoadedEvent.cs index abd2f0a..bbe04da 100644 --- a/GFramework.Game.Abstractions/data/events/DataLoadedEvent.cs +++ b/GFramework.Game.Abstractions/data/events/DataLoadedEvent.cs @@ -14,7 +14,7 @@ namespace GFramework.Game.Abstractions.data.events; /// -/// 表示数据加载完成事件的泛型类 +/// 表示数据加载完成事件的泛型类 /// /// 数据类型参数 /// 加载完成的数据对象 diff --git a/GFramework.Game.Abstractions/data/events/DataSavedEvent.cs b/GFramework.Game.Abstractions/data/events/DataSavedEvent.cs index 5a7ae28..a0b8fce 100644 --- a/GFramework.Game.Abstractions/data/events/DataSavedEvent.cs +++ b/GFramework.Game.Abstractions/data/events/DataSavedEvent.cs @@ -14,7 +14,7 @@ namespace GFramework.Game.Abstractions.data.events; /// -/// 表示数据保存事件的记录类型 +/// 表示数据保存事件的记录类型 /// /// 保存的数据类型 /// 保存的数据实例 diff --git a/GFramework.Game.Abstractions/setting/IResettable.cs b/GFramework.Game.Abstractions/setting/IResettable.cs index f9947d4..f00e254 100644 --- a/GFramework.Game.Abstractions/setting/IResettable.cs +++ b/GFramework.Game.Abstractions/setting/IResettable.cs @@ -1,8 +1,8 @@ namespace GFramework.Game.Abstractions.setting; /// -/// 可重置设置接口,继承自ISettingsSection接口 -/// 提供将设置重置为默认值的功能 +/// 可重置设置接口,继承自ISettingsSection接口 +/// 提供将设置重置为默认值的功能 /// public interface IResettable : ISettingsSection { diff --git a/GFramework.Game.Abstractions/setting/ISettingsMigration.cs b/GFramework.Game.Abstractions/setting/ISettingsMigration.cs index ee8388c..e8ccca0 100644 --- a/GFramework.Game.Abstractions/setting/ISettingsMigration.cs +++ b/GFramework.Game.Abstractions/setting/ISettingsMigration.cs @@ -14,27 +14,27 @@ namespace GFramework.Game.Abstractions.setting; /// -/// 定义设置数据迁移接口,用于处理不同版本设置数据之间的转换 +/// 定义设置数据迁移接口,用于处理不同版本设置数据之间的转换 /// public interface ISettingsMigration { /// - /// 获取要迁移的设置类型 + /// 获取要迁移的设置类型 /// Type SettingsType { get; } /// - /// 获取源版本号(迁移前的版本) + /// 获取源版本号(迁移前的版本) /// int FromVersion { get; } /// - /// 获取目标版本号(迁移后的版本) + /// 获取目标版本号(迁移后的版本) /// int ToVersion { get; } /// - /// 执行设置数据迁移操作 + /// 执行设置数据迁移操作 /// /// 需要迁移的旧版设置数据 /// 迁移后的新版设置数据 diff --git a/GFramework.Game.Abstractions/setting/ISettingsModel.cs b/GFramework.Game.Abstractions/setting/ISettingsModel.cs index 6131bbe..ea37d5d 100644 --- a/GFramework.Game.Abstractions/setting/ISettingsModel.cs +++ b/GFramework.Game.Abstractions/setting/ISettingsModel.cs @@ -30,13 +30,13 @@ public interface ISettingsModel : IModel T? GetApplicator() where T : class, IApplyAbleSettings; /// - /// 获取所有设置数据的集合 + /// 获取所有设置数据的集合 /// /// 包含所有设置数据的可枚举集合 IEnumerable AllData(); /// - /// 获取所有可应用设置的集合 + /// 获取所有可应用设置的集合 /// /// 包含所有可应用设置的可枚举集合 IEnumerable AllApplicators(); diff --git a/GFramework.Game.Abstractions/setting/data/LocalizationSettings.cs b/GFramework.Game.Abstractions/setting/data/LocalizationSettings.cs index a894464..edd9233 100644 --- a/GFramework.Game.Abstractions/setting/data/LocalizationSettings.cs +++ b/GFramework.Game.Abstractions/setting/data/LocalizationSettings.cs @@ -16,20 +16,20 @@ using GFramework.Core.Abstractions.versioning; namespace GFramework.Game.Abstractions.setting.data; /// -/// 本地化设置类,用于管理游戏的语言本地化配置 -/// 实现了ISettingsData接口提供设置数据功能,实现IVersioned接口提供版本控制功能 +/// 本地化设置类,用于管理游戏的语言本地化配置 +/// 实现了ISettingsData接口提供设置数据功能,实现IVersioned接口提供版本控制功能 /// public class LocalizationSettings : IResettable, IVersioned { /// - /// 获取或设置当前使用的语言 + /// 获取或设置当前使用的语言 /// /// 默认值为"简体中文" public string Language { get; set; } = "简体中文"; /// - /// 重置本地化设置到默认状态 - /// 将Language属性恢复为默认的"简体中文"值 + /// 重置本地化设置到默认状态 + /// 将Language属性恢复为默认的"简体中文"值 /// public void Reset() { @@ -37,7 +37,7 @@ public class LocalizationSettings : IResettable, IVersioned } /// - /// 获取或设置设置数据的版本号 + /// 获取或设置设置数据的版本号 /// /// 默认版本号为1 public int Version { get; set; } = 1; diff --git a/GFramework.Game/data/DataRepository.cs b/GFramework.Game/data/DataRepository.cs index 1de64dc..e6e0181 100644 --- a/GFramework.Game/data/DataRepository.cs +++ b/GFramework.Game/data/DataRepository.cs @@ -20,7 +20,7 @@ using GFramework.Game.Abstractions.data.events; namespace GFramework.Game.data; /// -/// 数据仓库类,用于管理游戏数据的存储和读取 +/// 数据仓库类,用于管理游戏数据的存储和读取 /// /// 存储接口实例 /// 数据仓库配置选项 @@ -35,7 +35,7 @@ public class DataRepository(IStorage? storage, DataRepositoryOptions? options = "Failed to initialize storage. No IStorage utility found in context."); /// - /// 异步加载指定类型的数据 + /// 异步加载指定类型的数据 /// /// 要加载的数据类型,必须实现IData接口 /// 加载的数据对象 @@ -46,13 +46,9 @@ public class DataRepository(IStorage? storage, DataRepositoryOptions? options = T result; // 检查存储中是否存在指定键的数据 if (await Storage.ExistsAsync(key)) - { result = await Storage.ReadAsync(key); - } else - { result = new T(); - } // 如果启用事件功能,则发送数据加载完成事件 if (_options.EnableEvents) @@ -62,7 +58,7 @@ public class DataRepository(IStorage? storage, DataRepositoryOptions? options = } /// - /// 异步加载指定类型的数据(通过Type参数) + /// 异步加载指定类型的数据(通过Type参数) /// /// 要加载的数据类型 /// 加载的数据对象 @@ -79,13 +75,9 @@ public class DataRepository(IStorage? storage, DataRepositoryOptions? options = IData result; // 检查存储中是否存在指定键的数据 if (await Storage.ExistsAsync(key)) - { result = await Storage.ReadAsync(key); - } else - { result = (IData)Activator.CreateInstance(type)!; - } // 如果启用事件功能,则发送数据加载完成事件 if (_options.EnableEvents) @@ -96,7 +88,7 @@ public class DataRepository(IStorage? storage, DataRepositoryOptions? options = /// - /// 异步保存指定类型的数据 + /// 异步保存指定类型的数据 /// /// 要保存的数据类型 /// 要保存的数据对象 @@ -119,7 +111,7 @@ public class DataRepository(IStorage? storage, DataRepositoryOptions? options = } /// - /// 检查指定类型的数据是否存在 + /// 检查指定类型的数据是否存在 /// /// 要检查的数据类型 /// 如果数据存在返回true,否则返回false @@ -130,7 +122,7 @@ public class DataRepository(IStorage? storage, DataRepositoryOptions? options = } /// - /// 异步删除指定类型的数据 + /// 异步删除指定类型的数据 /// /// 要删除的数据类型 public async Task DeleteAsync() where T : class, IData @@ -143,7 +135,7 @@ public class DataRepository(IStorage? storage, DataRepositoryOptions? options = } /// - /// 批量异步保存多个数据对象 + /// 批量异步保存多个数据对象 /// /// 要保存的数据对象集合 public async Task SaveAllAsync(IEnumerable dataList) @@ -166,14 +158,17 @@ public class DataRepository(IStorage? storage, DataRepositoryOptions? options = } /// - /// 根据类型生成存储键 + /// 根据类型生成存储键 /// /// 数据类型 /// 生成的存储键 - private string GetKey() where T : IData => GetKey(typeof(T)); + private string GetKey() where T : IData + { + return GetKey(typeof(T)); + } /// - /// 根据类型生成存储键 + /// 根据类型生成存储键 /// /// 数据类型 /// 生成的存储键 diff --git a/GFramework.Game/data/UnifiedSettingsRepository.cs b/GFramework.Game/data/UnifiedSettingsRepository.cs index 84c7b55..fbc5d99 100644 --- a/GFramework.Game/data/UnifiedSettingsRepository.cs +++ b/GFramework.Game/data/UnifiedSettingsRepository.cs @@ -21,7 +21,7 @@ using GFramework.Game.Abstractions.data.events; namespace GFramework.Game.data; /// -/// 使用单一文件存储所有设置数据的仓库实现 +/// 使用单一文件存储所有设置数据的仓库实现 /// public class UnifiedSettingsRepository( IStorage? storage, @@ -48,7 +48,7 @@ public class UnifiedSettingsRepository( // ========================= /// - /// 异步加载指定类型的数据 + /// 异步加载指定类型的数据 /// /// 要加载的数据类型,必须继承自IData接口并具有无参构造函数 /// 加载的数据实例 @@ -67,7 +67,7 @@ public class UnifiedSettingsRepository( } /// - /// 异步加载指定类型的数据(通过Type参数) + /// 异步加载指定类型的数据(通过Type参数) /// /// 要加载的数据类型 /// 加载的数据实例 @@ -86,13 +86,9 @@ public class UnifiedSettingsRepository( IData result; if (_cache.TryGetValue(key, out var json)) - { result = (IData)Serializer.Deserialize(json, type); - } else - { result = (IData)Activator.CreateInstance(type)!; - } if (_options.EnableEvents) this.SendEvent(new DataLoadedEvent(result)); @@ -101,7 +97,7 @@ public class UnifiedSettingsRepository( } /// - /// 异步保存数据到存储 + /// 异步保存数据到存储 /// /// 要保存的数据类型 /// 要保存的数据实例 @@ -119,7 +115,7 @@ public class UnifiedSettingsRepository( } /// - /// 异步批量保存多个数据实例 + /// 异步批量保存多个数据实例 /// /// 要保存的数据实例集合 public async Task SaveAllAsync(IEnumerable dataList) @@ -140,7 +136,7 @@ public class UnifiedSettingsRepository( } /// - /// 检查指定类型的数据是否存在 + /// 检查指定类型的数据是否存在 /// /// 要检查的数据类型 /// 如果存在返回true,否则返回false @@ -151,7 +147,7 @@ public class UnifiedSettingsRepository( } /// - /// 删除指定类型的数据 + /// 删除指定类型的数据 /// /// 要删除的数据类型 public async Task DeleteAsync() where T : class, IData @@ -176,7 +172,7 @@ public class UnifiedSettingsRepository( // ========================= /// - /// 确保数据已从存储中加载到缓存 + /// 确保数据已从存储中加载到缓存 /// private async Task EnsureLoadedAsync() { @@ -204,7 +200,7 @@ public class UnifiedSettingsRepository( } /// - /// 将缓存中的所有数据保存到统一文件 + /// 将缓存中的所有数据保存到统一文件 /// private async Task SaveUnifiedFileAsync() { @@ -220,7 +216,7 @@ public class UnifiedSettingsRepository( } /// - /// 获取统一文件的存储键名 + /// 获取统一文件的存储键名 /// /// 完整的存储键名 private string GetUnifiedKey() @@ -230,10 +226,13 @@ public class UnifiedSettingsRepository( } /// - /// 获取类型的唯一标识键 + /// 获取类型的唯一标识键 /// /// 要获取键的类型 /// 类型的全名作为键 private static string GetTypeKey(Type type) - => type.FullName!; // ⚠️ 刻意不用 AssemblyQualifiedName + { + return type.FullName!; + // ⚠️ 刻意不用 AssemblyQualifiedName + } } \ No newline at end of file diff --git a/GFramework.Game/serializer/JsonSerializer.cs b/GFramework.Game/serializer/JsonSerializer.cs index 7ded055..f49b958 100644 --- a/GFramework.Game/serializer/JsonSerializer.cs +++ b/GFramework.Game/serializer/JsonSerializer.cs @@ -16,7 +16,9 @@ public sealed class JsonSerializer /// 要序列化的对象实例 /// 序列化后的JSON字符串 public string Serialize(T value) - => JsonConvert.SerializeObject(value); + { + return JsonConvert.SerializeObject(value); + } /// /// 将JSON字符串反序列化为指定类型的对象 @@ -26,8 +28,10 @@ public sealed class JsonSerializer /// 反序列化后的对象实例 /// 当无法反序列化数据时抛出 public T Deserialize(string data) - => JsonConvert.DeserializeObject(data) - ?? throw new ArgumentException("Cannot deserialize data"); + { + return JsonConvert.DeserializeObject(data) + ?? throw new ArgumentException("Cannot deserialize data"); + } /// /// 将对象序列化为JSON字符串(使用运行时类型) @@ -36,7 +40,9 @@ public sealed class JsonSerializer /// 对象的运行时类型 /// 序列化后的JSON字符串 public string Serialize(object obj, Type type) - => JsonConvert.SerializeObject(obj, type, null); + { + return JsonConvert.SerializeObject(obj, type, null); + } /// /// 将JSON字符串反序列化为指定类型的对象(使用运行时类型) @@ -46,6 +52,8 @@ public sealed class JsonSerializer /// 反序列化后的对象实例 /// 当无法反序列化到指定类型时抛出 public object Deserialize(string data, Type type) - => JsonConvert.DeserializeObject(data, type) - ?? throw new ArgumentException($"Cannot deserialize to {type.Name}"); + { + return JsonConvert.DeserializeObject(data, type) + ?? throw new ArgumentException($"Cannot deserialize to {type.Name}"); + } } \ No newline at end of file diff --git a/GFramework.Game/setting/SettingsModel.cs b/GFramework.Game/setting/SettingsModel.cs index ab91655..8a86433 100644 --- a/GFramework.Game/setting/SettingsModel.cs +++ b/GFramework.Game/setting/SettingsModel.cs @@ -30,7 +30,7 @@ public class SettingsModel(IDataRepository? repository) // ----------------------------- /// - /// 获取指定类型的设置数据实例,如果不存在则创建新的实例 + /// 获取指定类型的设置数据实例,如果不存在则创建新的实例 /// /// 设置数据类型,必须实现ISettingsData接口并提供无参构造函数 /// 指定类型的设置数据实例 @@ -40,25 +40,29 @@ public class SettingsModel(IDataRepository? repository) } /// - /// 获取所有设置数据的枚举集合 + /// 获取所有设置数据的枚举集合 /// /// 所有设置数据的枚举集合 public IEnumerable AllData() - => _dataSettings.Values; + { + return _dataSettings.Values; + } // ----------------------------- // Applicator // ----------------------------- /// - /// 获取所有设置应用器的枚举集合 + /// 获取所有设置应用器的枚举集合 /// /// 所有设置应用器的枚举集合 public IEnumerable AllApplicators() - => _applicators.Values; + { + return _applicators.Values; + } /// - /// 注册设置应用器到模型中 + /// 注册设置应用器到模型中 /// /// 设置应用器类型,必须实现IApplyAbleSettings接口 /// 要注册的设置应用器实例 @@ -71,7 +75,7 @@ public class SettingsModel(IDataRepository? repository) } /// - /// 获取指定类型的设置应用器实例 + /// 获取指定类型的设置应用器实例 /// /// 设置应用器类型,必须实现IApplyAbleSettings接口 /// 指定类型的设置应用器实例,如果不存在则返回null @@ -87,7 +91,7 @@ public class SettingsModel(IDataRepository? repository) // ----------------------------- /// - /// 尝试获取指定类型的设置节 + /// 尝试获取指定类型的设置节 /// /// 要查找的设置类型 /// 输出参数,找到的设置节实例 @@ -115,7 +119,7 @@ public class SettingsModel(IDataRepository? repository) // ----------------------------- /// - /// 注册设置迁移器到模型中 + /// 注册设置迁移器到模型中 /// /// 要注册的设置迁移器实例 /// 当前设置模型实例,支持链式调用 @@ -131,7 +135,7 @@ public class SettingsModel(IDataRepository? repository) // ----------------------------- /// - /// 异步初始化设置模型,加载指定类型的设置数据 + /// 异步初始化设置模型,加载指定类型的设置数据 /// /// 要初始化的设置类型数组 public async Task InitializeAsync(params Type[] settingTypes) @@ -157,7 +161,7 @@ public class SettingsModel(IDataRepository? repository) } /// - /// 重置指定类型的可重置对象 + /// 重置指定类型的可重置对象 /// /// 要重置的对象类型,必须是class类型,实现IResettable接口,并具有无参构造函数 public void Reset() where T : class, IResettable, new() @@ -167,18 +171,15 @@ public class SettingsModel(IDataRepository? repository) } /// - /// 重置所有存储的数据设置对象 + /// 重置所有存储的数据设置对象 /// public void ResetAll() { - foreach (var data in _dataSettings.Values) - { - data.Reset(); - } + foreach (var data in _dataSettings.Values) data.Reset(); } /// - /// 如果需要的话,对设置节进行版本迁移 + /// 如果需要的话,对设置节进行版本迁移 /// /// 待检查和迁移的设置节 /// 迁移后的设置节 @@ -210,7 +211,7 @@ public class SettingsModel(IDataRepository? repository) /// - /// 初始化方法,用于获取设置持久化服务 + /// 初始化方法,用于获取设置持久化服务 /// protected override void OnInit() { diff --git a/GFramework.Game/setting/SettingsSystem.cs b/GFramework.Game/setting/SettingsSystem.cs index 449ea2b..4be3d77 100644 --- a/GFramework.Game/setting/SettingsSystem.cs +++ b/GFramework.Game/setting/SettingsSystem.cs @@ -23,10 +23,7 @@ public class SettingsSystem(IDataRepository? repository) public async Task ApplyAll() { // 遍历所有设置应用器并尝试应用 - foreach (var applicator in _model.AllApplicators()) - { - await TryApplyAsync(applicator); - } + foreach (var applicator in _model.AllApplicators()) await TryApplyAsync(applicator); } /// @@ -52,7 +49,7 @@ public class SettingsSystem(IDataRepository? repository) } /// - /// 重置所有设置并应用更改 + /// 重置所有设置并应用更改 /// /// 异步任务 public async Task ResetAll() @@ -62,7 +59,7 @@ public class SettingsSystem(IDataRepository? repository) } /// - /// 重置指定类型的设置并应用更改 + /// 重置指定类型的设置并应用更改 /// /// 设置类型,必须实现IPersistentApplyAbleSettings接口且具有无参构造函数 /// 异步任务 diff --git a/GFramework.Godot/coroutine/Timing.cs b/GFramework.Godot/coroutine/Timing.cs index 88ef374..3b850c2 100644 --- a/GFramework.Godot/coroutine/Timing.cs +++ b/GFramework.Godot/coroutine/Timing.cs @@ -181,8 +181,7 @@ public partial class Timing : Node _processScheduler = new CoroutineScheduler( _processTimeSource, - _instanceId, - 256 + _instanceId ); _physicsScheduler = new CoroutineScheduler( diff --git a/GFramework.Godot/setting/GodotAudioSettings.cs b/GFramework.Godot/setting/GodotAudioSettings.cs index 97db2a4..c5c3ac3 100644 --- a/GFramework.Godot/setting/GodotAudioSettings.cs +++ b/GFramework.Godot/setting/GodotAudioSettings.cs @@ -29,8 +29,10 @@ public class GodotAudioSettings(ISettingsModel model, AudioBusMap audioBusMap) /// /// 重置音频设置为默认值 /// - public void Reset() => + public void Reset() + { model.GetData().Reset(); + } /// /// 设置指定音频总线的音量 diff --git a/GFramework.Godot/setting/GodotGraphicsSettings.cs b/GFramework.Godot/setting/GodotGraphicsSettings.cs index 0d0b7fc..07d0e53 100644 --- a/GFramework.Godot/setting/GodotGraphicsSettings.cs +++ b/GFramework.Godot/setting/GodotGraphicsSettings.cs @@ -46,5 +46,8 @@ public class GodotGraphicsSettings(ISettingsModel model) : IPersistentApplyAbleS /// /// 重置图形设置 /// - public void Reset() => model.GetData().Reset(); + public void Reset() + { + model.GetData().Reset(); + } } \ No newline at end of file diff --git a/GFramework.Godot/setting/GodotLocalizationSettings.cs b/GFramework.Godot/setting/GodotLocalizationSettings.cs index 1c1f015..02cdb5f 100644 --- a/GFramework.Godot/setting/GodotLocalizationSettings.cs +++ b/GFramework.Godot/setting/GodotLocalizationSettings.cs @@ -19,7 +19,7 @@ using Godot; namespace GFramework.Godot.setting; /// -/// Godot本地化设置类,负责应用本地化配置到Godot引擎 +/// Godot本地化设置类,负责应用本地化配置到Godot引擎 /// /// 设置模型 /// 本地化映射表 @@ -27,7 +27,7 @@ public class GodotLocalizationSettings(ISettingsModel model, LocalizationMap loc : IPersistentApplyAbleSettings { /// - /// 应用本地化设置到Godot引擎 + /// 应用本地化设置到Godot引擎 /// /// 完成的任务 public Task Apply() @@ -41,7 +41,10 @@ public class GodotLocalizationSettings(ISettingsModel model, LocalizationMap loc } /// - /// 重置本地化设置 + /// 重置本地化设置 /// - public void Reset() => model.GetData().Reset(); + public void Reset() + { + model.GetData().Reset(); + } } \ No newline at end of file diff --git a/GFramework.Godot/setting/data/LocalizationMap.cs b/GFramework.Godot/setting/data/LocalizationMap.cs index 3501f5f..f0dca1b 100644 --- a/GFramework.Godot/setting/data/LocalizationMap.cs +++ b/GFramework.Godot/setting/data/LocalizationMap.cs @@ -14,12 +14,12 @@ namespace GFramework.Godot.setting.data; /// -/// 本地化映射设置 +/// 本地化映射设置 /// public class LocalizationMap { /// - /// 用户语言 -> Godot locale 映射表 + /// 用户语言 -> Godot locale 映射表 /// public Dictionary LanguageMap { get; set; } = new() {