Skip to content

Commit 8700755

Browse files
committed
docs: 为 DisposableConcurrentDictionary 添加英文注释
添加 XML 文档注释的英文翻译,以提升代码的国际化和可读性。
1 parent b3fe8af commit 8700755

1 file changed

Lines changed: 34 additions & 10 deletions

File tree

GameFrameX.Foundation.Extensions/DisposableConcurrentDictionary.cs

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,47 @@
11
namespace GameFrameX.Foundation.Extensions;
22

33
/// <summary>
4-
/// 值可被Dispose的并发字典类型
4+
/// 值可被Dispose的并发字典类型
55
/// </summary>
6-
/// <typeparam name="TKey">键的类型。</typeparam>
7-
/// <typeparam name="TValue">值的类型,必须实现IDisposable接口。</typeparam>
6+
/// <remarks>
7+
/// A concurrent dictionary type whose values can be disposed.
8+
/// </remarks>
9+
/// <typeparam name="TKey">键的类型 / The type of the key.</typeparam>
10+
/// <typeparam name="TValue">值的类型,必须实现IDisposable接口 / The type of the value, must implement IDisposable interface.</typeparam>
811
public class DisposableConcurrentDictionary<TKey, TValue> : NullableConcurrentDictionary<TKey, TValue>, IDisposable where TValue : IDisposable
912
{
1013
private bool _isDisposed;
1114

1215
/// <summary>
1316
/// 初始化一个新的 <see cref="DisposableConcurrentDictionary{TKey, TValue}" /> 实例。
1417
/// </summary>
18+
/// <remarks>
19+
/// Initializes a new instance of the <see cref="DisposableConcurrentDictionary{TKey, TValue}" /> class.
20+
/// </remarks>
1521
public DisposableConcurrentDictionary()
1622
{
1723
}
1824

1925
/// <summary>
2026
/// 使用指定的默认值初始化一个新的 <see cref="DisposableConcurrentDictionary{TKey, TValue}" /> 实例。
2127
/// </summary>
22-
/// <param name="fallbackValue">当键不存在时返回的默认值。</param>
28+
/// <remarks>
29+
/// Initializes a new instance of the <see cref="DisposableConcurrentDictionary{TKey, TValue}" /> class with the specified default value.
30+
/// </remarks>
31+
/// <param name="fallbackValue">当键不存在时返回的默认值 / The default value to return when a key does not exist.</param>
2332
public DisposableConcurrentDictionary(TValue fallbackValue) : base(fallbackValue)
2433
{
2534
}
2635

2736
/// <summary>
2837
/// 使用指定的并发级别和初始容量初始化一个新的 <see cref="DisposableConcurrentDictionary{TKey, TValue}" /> 实例。
2938
/// </summary>
30-
/// <param name="concurrencyLevel">并发级别,即字典可以同时支持的线程数,必须大于0。</param>
31-
/// <param name="capacity">字典的初始容量,必须大于等于0。</param>
32-
/// <exception cref="ArgumentOutOfRangeException">当 concurrencyLevel 小于等于 0 或 capacity 小于 0 时抛出。</exception>
39+
/// <remarks>
40+
/// Initializes a new instance of the <see cref="DisposableConcurrentDictionary{TKey, TValue}" /> class with the specified concurrency level and initial capacity.
41+
/// </remarks>
42+
/// <param name="concurrencyLevel">并发级别,即字典可以同时支持的线程数,必须大于0 / The number of threads that can access the dictionary concurrently, must be greater than 0.</param>
43+
/// <param name="capacity">字典的初始容量,必须大于等于0 / The initial number of elements that the dictionary can contain, must be greater than or equal to 0.</param>
44+
/// <exception cref="ArgumentOutOfRangeException">当 <paramref name="concurrencyLevel"/> 小于等于 0 或 <paramref name="capacity"/> 小于 0 时抛出 / Thrown when <paramref name="concurrencyLevel"/> is less than or equal to 0 or <paramref name="capacity"/> is less than 0.</exception>
3345
public DisposableConcurrentDictionary(int concurrencyLevel, int capacity) : base(concurrencyLevel, capacity)
3446
{
3547
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(concurrencyLevel, nameof(concurrencyLevel));
@@ -39,8 +51,11 @@ public DisposableConcurrentDictionary(int concurrencyLevel, int capacity) : base
3951
/// <summary>
4052
/// 使用指定的比较器初始化一个新的 <see cref="DisposableConcurrentDictionary{TKey, TValue}" /> 实例。
4153
/// </summary>
42-
/// <param name="comparer">用于比较键的比较器,不能为null。</param>
43-
/// <exception cref="ArgumentNullException">当 comparer 为 null 时抛出。</exception>
54+
/// <remarks>
55+
/// Initializes a new instance of the <see cref="DisposableConcurrentDictionary{TKey, TValue}" /> class with the specified comparer.
56+
/// </remarks>
57+
/// <param name="comparer">用于比较键的比较器,不能为null / The equality comparison implementation to use when comparing keys, cannot be null.</param>
58+
/// <exception cref="ArgumentNullException">当 <paramref name="comparer"/> 为 null 时抛出 / Thrown when <paramref name="comparer"/> is null.</exception>
4459
public DisposableConcurrentDictionary(IEqualityComparer<NullObject<TKey>> comparer) : base(comparer)
4560
{
4661
ArgumentNullException.ThrowIfNull(comparer, nameof(comparer));
@@ -49,6 +64,9 @@ public DisposableConcurrentDictionary(IEqualityComparer<NullObject<TKey>> compar
4964
/// <summary>
5065
/// 释放资源。
5166
/// </summary>
67+
/// <remarks>
68+
/// Releases all resources used by this instance.
69+
/// </remarks>
5270
public void Dispose()
5371
{
5472
if (_isDisposed)
@@ -64,6 +82,9 @@ public void Dispose()
6482
/// <summary>
6583
/// 终结器,确保未释放的资源在对象被垃圾回收时被释放。
6684
/// </summary>
85+
/// <remarks>
86+
/// Finalizer to ensure unmanaged resources are released when the object is garbage collected.
87+
/// </remarks>
6788
~DisposableConcurrentDictionary()
6889
{
6990
Dispose(false);
@@ -72,7 +93,10 @@ public void Dispose()
7293
/// <summary>
7394
/// 释放资源。
7495
/// </summary>
75-
/// <param name="disposing">指示是否应释放托管资源。</param>
96+
/// <remarks>
97+
/// Releases the unmanaged resources used by the <see cref="DisposableConcurrentDictionary{TKey, TValue}"/> and optionally releases the managed resources.
98+
/// </remarks>
99+
/// <param name="disposing">指示是否应释放托管资源 / true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
76100
protected virtual void Dispose(bool disposing)
77101
{
78102
if (disposing)

0 commit comments

Comments
 (0)