mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
refactor(storage): 重构存储接口实现
- 将FileStorage类的接口从IStorage改为IFileStorage - 添加IFileStorage接口定义,继承自IStorage接口 - 将ScopedStorage类的接口从IStorage改为IScopedStorage - 添加IScopedStorage接口定义,继承自IStorage接口 - 更新相关命名空间引用 - 修改FileStorage类的XML注释文档
This commit is contained in:
parent
a30e576c03
commit
c223fbcb5c
@ -52,7 +52,8 @@ public class GFrameworkConstantsTests
|
||||
// 如果常量不存在或不是公共的,编译会失败或抛出异常
|
||||
Assert.DoesNotThrow(() =>
|
||||
{
|
||||
var name = GFrameworkConstants.FrameworkName;
|
||||
const string name = GFrameworkConstants.FrameworkName;
|
||||
Console.WriteLine(name);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
9
GFramework.Game.Abstractions/storage/IFileStorage.cs
Normal file
9
GFramework.Game.Abstractions/storage/IFileStorage.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using GFramework.Core.Abstractions.storage;
|
||||
|
||||
namespace GFramework.Game.Abstractions.storage;
|
||||
|
||||
/// <summary>
|
||||
/// 文件存储接口,定义了文件存储操作的契约
|
||||
/// 继承自IStorage接口,提供专门针对文件的存储功能
|
||||
/// </summary>
|
||||
public interface IFileStorage : IStorage;
|
||||
8
GFramework.Game.Abstractions/storage/IScopedStorage.cs
Normal file
8
GFramework.Game.Abstractions/storage/IScopedStorage.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using GFramework.Core.Abstractions.storage;
|
||||
|
||||
namespace GFramework.Game.Abstractions.storage;
|
||||
|
||||
/// <summary>
|
||||
/// 表示作用域存储接口,继承自基础存储接口
|
||||
/// </summary>
|
||||
public interface IScopedStorage : IStorage;
|
||||
@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// 基于文件系统的存储实现,实现了IStorage接口,支持按key细粒度锁保证线程安全
|
||||
/// 基于文件系统的存储实现,实现了IFileStorage接口,支持按key细粒度锁保证线程安全
|
||||
/// </summary>
|
||||
public sealed class FileStorage : IStorage
|
||||
public sealed class FileStorage : IFileStorage
|
||||
{
|
||||
private readonly string _extension;
|
||||
|
||||
|
||||
@ -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;
|
||||
/// </summary>
|
||||
/// <param name="inner">内部的实际存储实现</param>
|
||||
/// <param name="prefix">用于所有键的前缀字符串</param>
|
||||
public sealed class ScopedStorage(IStorage inner, string prefix) : IStorage
|
||||
public sealed class ScopedStorage(IStorage inner, string prefix) : IScopedStorage
|
||||
{
|
||||
/// <summary>
|
||||
/// 检查指定键是否存在
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user