Skip to content

Commit 934117d

Browse files
committed
docs(database/mongo): 添加双语文档注释
为 MongoDB 数据库模块的所有公共 API 添加标准双语文档注释: - CacheState: 缓存状态基类 - MongoDbContext: 数据库上下文 - MongoDbService: 主服务类及各 partial 类 - MongoDbHealthCheck: 健康检查实现 注释规范:summary 使用中文,remarks 使用英文,param/returns 使用双语格式
1 parent 3048b3e commit 934117d

10 files changed

Lines changed: 405 additions & 147 deletions

GameFrameX.DataBase.Mongo/CacheState.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,21 @@
3535
namespace GameFrameX.DataBase.Mongo;
3636

3737
/// <summary>
38-
/// 缓存数据对象
38+
/// 缓存数据对象
3939
/// </summary>
40+
/// <remarks>
41+
/// Cache data object.
42+
/// </remarks>
4043
[BsonIgnoreExtraElements(true, Inherited = true)]
4144
public class CacheState : BaseCacheState
4245
{
4346
/// <summary>
44-
/// 将对象序列化转换为字节数组
47+
/// 将对象序列化转换为字节数组
4548
/// </summary>
46-
/// <returns></returns>
49+
/// <remarks>
50+
/// Serializes the object to a byte array.
51+
/// </remarks>
52+
/// <returns>序列化后的字节数组 / Serialized byte array</returns>
4753
public override byte[] ToBytes()
4854
{
4955
return this.ToBson();

GameFrameX.DataBase.Mongo/HealthChecks/MongoDbHealthCheck.cs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,36 @@
3535
namespace GameFrameX.DataBase.Mongo.HealthChecks;
3636

3737
/// <summary>
38-
/// MongoDB 健康检查类
38+
/// MongoDB 健康检查类
3939
/// </summary>
40+
/// <remarks>
41+
/// MongoDB health check class.
42+
/// </remarks>
4043
public sealed class MongoDbHealthCheck : IHealthCheck
4144
{
4245
private readonly IMongoClient _mongoClient;
4346

4447
/// <summary>
45-
/// 初始化 MongoDbHealthCheck 的新实例
48+
/// 初始化 MongoDbHealthCheck 的新实例
4649
/// </summary>
47-
/// <param name="mongoClient">MongoDB 客户端</param>
50+
/// <remarks>
51+
/// Initializes a new instance of MongoDbHealthCheck.
52+
/// </remarks>
53+
/// <param name="mongoClient">MongoDB 客户端 / MongoDB client</param>
4854
public MongoDbHealthCheck(IMongoClient mongoClient)
4955
{
5056
_mongoClient = mongoClient;
5157
}
5258

5359
/// <summary>
54-
/// 执行健康检查
60+
/// 执行健康检查
5561
/// </summary>
56-
/// <param name="context">健康检查上下文</param>
57-
/// <param name="cancellationToken">取消令牌</param>
58-
/// <returns>健康检查结果</returns>
62+
/// <remarks>
63+
/// Performs the health check.
64+
/// </remarks>
65+
/// <param name="context">健康检查上下文 / Health check context</param>
66+
/// <param name="cancellationToken">取消令牌 / Cancellation token</param>
67+
/// <returns>健康检查结果 / Health check result</returns>
5968
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
6069
{
6170
try

GameFrameX.DataBase.Mongo/MongoDbContext.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,21 @@
3434

3535
namespace GameFrameX.DataBase.Mongo;
3636

37+
/// <summary>
38+
/// MongoDB 数据库上下文。
39+
/// </summary>
40+
/// <remarks>
41+
/// MongoDB database context.
42+
/// </remarks>
3743
internal sealed class MongoDbContext : DB
3844
{
45+
/// <summary>
46+
/// 初始化 MongoDB 数据库上下文的新实例。
47+
/// </summary>
48+
/// <remarks>
49+
/// Initializes a new instance of the MongoDB database context.
50+
/// </remarks>
51+
/// <param name="dbName">数据库名称 / Database name</param>
3952
public MongoDbContext(string dbName) : base(Instance(dbName))
4053
{
4154
SetGlobalFilterForBaseClass<BaseCacheState>(m => m.IsDeleted == null || m.IsDeleted == false);

GameFrameX.DataBase.Mongo/MongoDbService.Add.cs

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ namespace GameFrameX.DataBase.Mongo;
4444
/// </see>
4545
/// 接口。
4646
/// </summary>
47+
/// <remarks>
48+
/// MongoDB service connection class that implements the
49+
/// <see>
50+
/// <cref>IDatabaseService</cref>
51+
/// </see>
52+
/// interface.
53+
/// </remarks>
4754
public sealed partial class MongoDbService
4855
{
4956
/// <summary>
@@ -53,16 +60,26 @@ public sealed partial class MongoDbService
5360
/// </see>
5461
/// 属性为 false 可以并行执行写入操作。
5562
/// </summary>
63+
/// <remarks>
64+
/// Bulk write options for batch document writing. Setting the
65+
/// <see>
66+
/// <cref>IsOrdered</cref>
67+
/// </see>
68+
/// property to false enables parallel write operations.
69+
/// </remarks>
5670
public static readonly BulkWriteOptions BulkWriteOptions = new() { IsOrdered = false, };
5771

5872
#region 插入
5973

6074
/// <summary>
61-
/// 增加一条数据
75+
/// 增加一条数据
6276
/// </summary>
63-
/// <param name="state"></param>
64-
/// <typeparam name="TState"></typeparam>
65-
/// <returns>返回修改的条数</returns>
77+
/// <remarks>
78+
/// Adds a single data record.
79+
/// </remarks>
80+
/// <typeparam name="TState">数据类型,必须继承自 BaseCacheState / Data type, must inherit from BaseCacheState</typeparam>
81+
/// <param name="state">要添加的数据对象 / Data object to add</param>
82+
/// <returns>表示异步操作的任务 / A task representing the asynchronous operation</returns>
6683
public async Task AddAsync<TState>(TState state) where TState : BaseCacheState, new()
6784
{
6885
EnsureInitialized();
@@ -72,10 +89,14 @@ public sealed partial class MongoDbService
7289
}
7390

7491
/// <summary>
75-
/// 增加一个列表数据
92+
/// 增加一个列表数据
7693
/// </summary>
77-
/// <param name="states"></param>
78-
/// <typeparam name="TState"></typeparam>
94+
/// <remarks>
95+
/// Adds a list of data records.
96+
/// </remarks>
97+
/// <typeparam name="TState">数据类型,必须继承自 BaseCacheState / Data type, must inherit from BaseCacheState</typeparam>
98+
/// <param name="states">要添加的数据列表 / List of data objects to add</param>
99+
/// <returns>表示异步操作的任务 / A task representing the asynchronous operation</returns>
79100
public async Task AddListAsync<TState>(IEnumerable<TState> states) where TState : BaseCacheState, new()
80101
{
81102
EnsureInitialized();

GameFrameX.DataBase.Mongo/MongoDbService.Delete.cs

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,24 @@ namespace GameFrameX.DataBase.Mongo;
4141
/// </see>
4242
/// 接口。
4343
/// </summary>
44+
/// <remarks>
45+
/// MongoDB service connection class that implements the
46+
/// <see>
47+
/// <cref>IDatabaseService</cref>
48+
/// </see>
49+
/// interface.
50+
/// </remarks>
4451
public sealed partial class MongoDbService
4552
{
4653
/// <summary>
47-
/// 根据条件删除单条数据(软删除)
54+
/// 根据条件删除单条数据软删除)。
4855
/// </summary>
49-
/// <param name="filter">查询条件表达式</param>
50-
/// <typeparam name="TState">数据类型,必须继承自BaseCacheState</typeparam>
51-
/// <returns>返回修改的记录数</returns>
56+
/// <remarks>
57+
/// Deletes a single data record by condition (soft delete).
58+
/// </remarks>
59+
/// <typeparam name="TState">数据类型,必须继承自 BaseCacheState / Data type, must inherit from BaseCacheState</typeparam>
60+
/// <param name="filter">查询条件表达式 / Query condition expression</param>
61+
/// <returns>返回修改的记录数 / The number of modified records</returns>
5262
public async Task<long> DeleteAsync<TState>(Expression<Func<TState, bool>> filter) where TState : BaseCacheState, new()
5363
{
5464
EnsureInitialized();
@@ -60,11 +70,14 @@ public sealed partial class MongoDbService
6070
}
6171

6272
/// <summary>
63-
/// 根据条件批量删除数据(软删除)
73+
/// 根据条件批量删除数据软删除)。
6474
/// </summary>
65-
/// <param name="filter">查询条件表达式</param>
66-
/// <typeparam name="TState">数据类型,必须继承自BaseCacheState</typeparam>
67-
/// <returns>返回修改的记录数</returns>
75+
/// <remarks>
76+
/// Batch deletes data by condition (soft delete).
77+
/// </remarks>
78+
/// <typeparam name="TState">数据类型,必须继承自 BaseCacheState / Data type, must inherit from BaseCacheState</typeparam>
79+
/// <param name="filter">查询条件表达式 / Query condition expression</param>
80+
/// <returns>返回修改的记录数 / The number of modified records</returns>
6881
public async Task<long> DeleteListAsync<TState>(Expression<Func<TState, bool>> filter) where TState : BaseCacheState, new()
6982
{
7083
EnsureInitialized();
@@ -83,11 +96,14 @@ public sealed partial class MongoDbService
8396
}
8497

8598
/// <summary>
86-
/// 根据ID列表批量删除数据(软删除)
99+
/// 根据ID列表批量删除数据软删除)。
87100
/// </summary>
88-
/// <param name="ids">要删除的ID列表</param>
89-
/// <typeparam name="TState">数据类型,必须继承自BaseCacheState</typeparam>
90-
/// <returns>返回修改的记录数</returns>
101+
/// <remarks>
102+
/// Batch deletes data by ID list (soft delete).
103+
/// </remarks>
104+
/// <typeparam name="TState">数据类型,必须继承自 BaseCacheState / Data type, must inherit from BaseCacheState</typeparam>
105+
/// <param name="ids">要删除的ID列表 / List of IDs to delete</param>
106+
/// <returns>返回修改的记录数 / The number of modified records</returns>
91107
public async Task<long> DeleteListIdAsync<TState>(IEnumerable<long> ids) where TState : BaseCacheState, new()
92108
{
93109
EnsureInitialized();
@@ -103,11 +119,14 @@ public sealed partial class MongoDbService
103119
}
104120

105121
/// <summary>
106-
/// 删除指定对象(软删除)
122+
/// 删除指定对象软删除)。
107123
/// </summary>
108-
/// <param name="state">要删除的对象</param>
109-
/// <typeparam name="TState">数据类型,必须继承自BaseCacheState</typeparam>
110-
/// <returns>返回修改的记录数</returns>
124+
/// <remarks>
125+
/// Deletes the specified object (soft delete).
126+
/// </remarks>
127+
/// <typeparam name="TState">数据类型,必须继承自 BaseCacheState / Data type, must inherit from BaseCacheState</typeparam>
128+
/// <param name="state">要删除的对象 / Object to delete</param>
129+
/// <returns>返回修改的记录数 / The number of modified records</returns>
111130
public async Task<long> DeleteAsync<TState>(TState state) where TState : BaseCacheState, new()
112131
{
113132
EnsureInitialized();

0 commit comments

Comments
 (0)