From c223fbcb5ce6b06eae250b6e56b6160af8223820 Mon Sep 17 00:00:00 2001 From: GeWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Mon, 19 Jan 2026 19:08:59 +0800 Subject: [PATCH] =?UTF-8?q?refactor(storage):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E5=AD=98=E5=82=A8=E6=8E=A5=E5=8F=A3=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将FileStorage类的接口从IStorage改为IFileStorage - 添加IFileStorage接口定义,继承自IStorage接口 - 将ScopedStorage类的接口从IStorage改为IScopedStorage - 添加IScopedStorage接口定义,继承自IStorage接口 - 更新相关命名空间引用 - 修改FileStorage类的XML注释文档 --- .../constants/GFrameworkConstantsTests.cs | 3 ++- GFramework.Game.Abstractions/storage/IFileStorage.cs | 9 +++++++++ GFramework.Game.Abstractions/storage/IScopedStorage.cs | 8 ++++++++ GFramework.Game/storage/FileStorage.cs | 6 +++--- GFramework.Game/storage/ScopedStorage.cs | 3 ++- 5 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 GFramework.Game.Abstractions/storage/IFileStorage.cs create mode 100644 GFramework.Game.Abstractions/storage/IScopedStorage.cs diff --git a/GFramework.Core.Tests/constants/GFrameworkConstantsTests.cs b/GFramework.Core.Tests/constants/GFrameworkConstantsTests.cs index 606e259..99f2894 100644 --- a/GFramework.Core.Tests/constants/GFrameworkConstantsTests.cs +++ b/GFramework.Core.Tests/constants/GFrameworkConstantsTests.cs @@ -52,7 +52,8 @@ public class GFrameworkConstantsTests // 如果常量不存在或不是公共的,编译会失败或抛出异常 Assert.DoesNotThrow(() => { - var name = GFrameworkConstants.FrameworkName; + const string name = GFrameworkConstants.FrameworkName; + Console.WriteLine(name); }); } diff --git a/GFramework.Game.Abstractions/storage/IFileStorage.cs b/GFramework.Game.Abstractions/storage/IFileStorage.cs new file mode 100644 index 0000000..f8b17f4 --- /dev/null +++ b/GFramework.Game.Abstractions/storage/IFileStorage.cs @@ -0,0 +1,9 @@ +using GFramework.Core.Abstractions.storage; + +namespace GFramework.Game.Abstractions.storage; + +/// +/// 文件存储接口,定义了文件存储操作的契约 +/// 继承自IStorage接口,提供专门针对文件的存储功能 +/// +public interface IFileStorage : IStorage; \ No newline at end of file diff --git a/GFramework.Game.Abstractions/storage/IScopedStorage.cs b/GFramework.Game.Abstractions/storage/IScopedStorage.cs new file mode 100644 index 0000000..148586f --- /dev/null +++ b/GFramework.Game.Abstractions/storage/IScopedStorage.cs @@ -0,0 +1,8 @@ +using GFramework.Core.Abstractions.storage; + +namespace GFramework.Game.Abstractions.storage; + +/// +/// 表示作用域存储接口,继承自基础存储接口 +/// +public interface IScopedStorage : IStorage; \ No newline at end of file diff --git a/GFramework.Game/storage/FileStorage.cs b/GFramework.Game/storage/FileStorage.cs index 826280f..b75ed8a 100644 --- a/GFramework.Game/storage/FileStorage.cs +++ b/GFramework.Game/storage/FileStorage.cs @@ -1,14 +1,14 @@ using System.Collections.Concurrent; using System.Text; -using GFramework.Core.Abstractions.storage; using GFramework.Game.Abstractions.serializer; +using GFramework.Game.Abstractions.storage; namespace GFramework.Game.storage; /// -/// 基于文件系统的存储实现,实现了IStorage接口,支持按key细粒度锁保证线程安全 +/// 基于文件系统的存储实现,实现了IFileStorage接口,支持按key细粒度锁保证线程安全 /// -public sealed class FileStorage : IStorage +public sealed class FileStorage : IFileStorage { private readonly string _extension; diff --git a/GFramework.Game/storage/ScopedStorage.cs b/GFramework.Game/storage/ScopedStorage.cs index ba85f19..2f9ca5b 100644 --- a/GFramework.Game/storage/ScopedStorage.cs +++ b/GFramework.Game/storage/ScopedStorage.cs @@ -1,4 +1,5 @@ using GFramework.Core.Abstractions.storage; +using GFramework.Game.Abstractions.storage; namespace GFramework.Game.storage; @@ -7,7 +8,7 @@ namespace GFramework.Game.storage; /// /// 内部的实际存储实现 /// 用于所有键的前缀字符串 -public sealed class ScopedStorage(IStorage inner, string prefix) : IStorage +public sealed class ScopedStorage(IStorage inner, string prefix) : IScopedStorage { /// /// 检查指定键是否存在