Skip to content

Commit f186667

Browse files
committed
docs(extensions): 为扩展方法添加英文文档注释
为 TimerExtension 和 TypeExtensions 类中的方法添加英文文档注释,以支持国际化开发。
1 parent d5054dc commit f186667

2 files changed

Lines changed: 55 additions & 57 deletions

File tree

GameFrameX.Foundation.Extensions/TimerExtension.cs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,30 @@
3636
namespace GameFrameX.Foundation.Extensions;
3737

3838
/// <summary>
39-
/// Timer 扩展方法类
39+
/// Timer 扩展方法类
4040
/// </summary>
41+
/// <remarks>
42+
/// Provides extension methods for the <see cref="System.Timers.Timer"/> class.
43+
/// </remarks>
4144
public static class TimerExtension
4245
{
4346
/// <summary>
44-
/// 重置计时器,停止当前计时并重新开始
47+
/// 重置计时器,停止当前计时并重新开始
4548
/// </summary>
46-
/// <param name="timer">要重置的计时器实例</param>
47-
/// <exception cref="ArgumentNullException">当 timer 为 null 时抛出此异常</exception>
48-
/// <exception cref="ObjectDisposedException">当 timer 已被释放时抛出此异常</exception>
4949
/// <remarks>
50-
/// 此方法会先停止计时器,然后重新启动它,相当于重置计时器的计时周期。
51-
/// 计时器的配置(如间隔时间、自动重置设置等)将保持不变。
50+
/// Resets the timer, stopping the current timing and restarting it.
51+
/// This method first stops the timer and then restarts it, effectively resetting the timing cycle.
52+
/// The timer's configuration (such as interval, auto-reset settings, etc.) remains unchanged.
5253
/// </remarks>
54+
/// <param name="timer">要重置的计时器实例 / The timer instance to reset.</param>
55+
/// <exception cref="ArgumentNullException">当 <paramref name="timer"/> 为 null 时抛出此异常 / Thrown when <paramref name="timer"/> is null.</exception>
56+
/// <exception cref="ObjectDisposedException">当 <paramref name="timer"/> 已被释放时抛出此异常 / Thrown when <paramref name="timer"/> has been disposed.</exception>
5357
/// <example>
5458
/// <code>
55-
/// var timer = new Timer(1000); // 1秒间隔
59+
/// var timer = new Timer(1000); // 1秒间隔 / 1 second interval
5660
/// timer.Start();
57-
/// // ... 一段时间后
58-
/// timer.Reset(); // 重置计时器,重新开始计时
61+
/// // ... 一段时间后 / ... after some time
62+
/// timer.Reset(); // 重置计时器,重新开始计时 / Reset the timer and restart timing
5963
/// </code>
6064
/// </example>
6165
public static void Reset(this Timer timer)

GameFrameX.Foundation.Extensions/TypeExtensions.cs

Lines changed: 41 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,25 @@
3838
namespace GameFrameX.Foundation.Extensions;
3939

4040
/// <summary>
41-
/// 类型扩展类,提供了一系列用于类型检查和判断的扩展方法
41+
/// 类型扩展类,提供了一系列用于类型检查和判断的扩展方法
4242
/// </summary>
43+
/// <remarks>
44+
/// Provides extension methods for type checking and validation.
45+
/// </remarks>
4346
public static partial class TypeExtensions
4447
{
4548
/// <summary>
46-
/// 判断类型是否实现了指定的接口
49+
/// 判断类型是否实现了指定的接口
4750
/// </summary>
48-
/// <param name="targetType">要检查的类型,不能为null</param>
49-
/// <param name="interfaceType">目标接口类型,不能为null</param>
50-
/// <returns>
51-
/// 如果类型实现了指定的接口,则返回true;
52-
/// 否则返回false
53-
/// </returns>
5451
/// <remarks>
55-
/// 此方法会检查类型是否直接或间接地实现了指定的接口。
56-
/// 它会递归检查类型的继承链和接口实现。
52+
/// Checks whether the type implements the specified interface.
53+
/// This method checks both direct and indirect interface implementations by recursively examining the type's inheritance chain.
5754
/// </remarks>
58-
/// <exception cref="ArgumentNullException">当<paramref name="targetType"/>或<paramref name="interfaceType"/>为null时抛出</exception>
59-
/// <exception cref="ArgumentException">当<paramref name="interfaceType"/>不是接口类型时抛出</exception>
55+
/// <param name="targetType">要检查的类型,不能为null / The type to check, cannot be null.</param>
56+
/// <param name="interfaceType">目标接口类型,不能为null / The interface type to check for, cannot be null.</param>
57+
/// <returns>如果类型实现了指定的接口,则返回true;否则返回false / true if the type implements the specified interface; otherwise, false.</returns>
58+
/// <exception cref="ArgumentNullException">当 <paramref name="targetType"/> 或 <paramref name="interfaceType"/> 为 null 时抛出 / Thrown when <paramref name="targetType"/> or <paramref name="interfaceType"/> is null.</exception>
59+
/// <exception cref="ArgumentException">当 <paramref name="interfaceType"/> 不是接口类型时抛出 / Thrown when <paramref name="interfaceType"/> is not an interface type.</exception>
6060
public static bool HasInterface(Type targetType, Type interfaceType)
6161
{
6262
ArgumentNullException.ThrowIfNull(targetType, nameof(targetType));
@@ -71,21 +71,19 @@ public static bool HasInterface(Type targetType, Type interfaceType)
7171
}
7272

7373
/// <summary>
74-
/// 判断类型是否实现某个泛型接口或继承自某个泛型类
74+
/// 判断类型是否实现某个泛型接口或继承自某个泛型类
7575
/// </summary>
76-
/// <param name="type">要检查的类型,不能为null</param>
77-
/// <param name="generic">目标泛型类型,不能为null</param>
78-
/// <returns>
79-
/// 如果类型实现了指定的泛型接口或继承自指定的泛型类,则返回true;
80-
/// 否则返回false
81-
/// </returns>
8276
/// <remarks>
83-
/// 此方法会递归检查类型的继承链和接口实现:
84-
/// 1. 首先检查类型实现的所有接口
85-
/// 2. 然后沿着继承链向上检查基类
86-
/// 3. 对于泛型类型,会提取其泛型类型定义进行比较
77+
/// Checks whether the type implements a specific generic interface or inherits from a specific generic class.
78+
/// This method recursively checks:
79+
/// 1. All interfaces implemented by the type
80+
/// 2. The inheritance chain of base classes
81+
/// 3. For generic types, extracts the generic type definition for comparison
8782
/// </remarks>
88-
/// <exception cref="ArgumentNullException">当<paramref name="type"/>或<paramref name="generic"/>为null时抛出</exception>
83+
/// <param name="type">要检查的类型,不能为null / The type to check, cannot be null.</param>
84+
/// <param name="generic">目标泛型类型,不能为null / The generic type to check for, cannot be null.</param>
85+
/// <returns>如果类型实现了指定的泛型接口或继承自指定的泛型类,则返回true;否则返回false / true if the type implements the specified generic interface or inherits from the specified generic class; otherwise, false.</returns>
86+
/// <exception cref="ArgumentNullException">当 <paramref name="type"/> 或 <paramref name="generic"/> 为 null 时抛出 / Thrown when <paramref name="type"/> or <paramref name="generic"/> is null.</exception>
8987
public static bool HasImplementedRawGeneric(this Type type, Type generic)
9088
{
9189
// 参数检查
@@ -124,31 +122,27 @@ bool IsTheRawGenericType(Type rawGenericType)
124122
/// 判断类型是否实现了指定的接口。
125123
/// 此方法用于检查一个具体类型是否实现了目标接口。
126124
/// </summary>
127-
/// <param name="self">要判断的类型。必须是非空的具体类型。</param>
128-
/// <param name="target">要判断的接口类型。必须是非空的接口类型。</param>
129-
/// <param name="directOnly">是否只检查直接实现的接口,不检查继承的接口。
130-
/// 当设置为true时,只检查直接实现的接口;
131-
/// 当设置为false时,同时检查继承链上的所有接口。</param>
132-
/// <param name="checkIndirectInterfaces">是否检查接口之间的继承关系。
133-
/// 当设置为true时,会检查接口之间的继承关系;
134-
/// 当设置为false时,只检查类型直接实现的接口列表。</param>
135-
/// <returns>
136-
/// 如果self实现了target接口(根据directOnly和checkIndirectInterfaces参数决定检查范围),则返回true;
137-
/// 否则返回false
138-
/// </returns>
139125
/// <remarks>
140-
/// 使用场景示例:
141-
/// 1. 在反射中判断某个类型是否可以用于特定接口的实现
142-
/// 2. 在依赖注入场景中验证服务实现的有效性
143-
/// 3. 在插件系统中检查插件类型是否符合要求
144-
///
145-
/// 参数组合效果:
146-
/// - directOnly=true, checkIndirectInterfaces=false:只检查类型直接实现的接口
147-
/// - directOnly=false, checkIndirectInterfaces=false:检查类型实现的所有接口,但不检查接口之间的继承关系
148-
/// - directOnly=false, checkIndirectInterfaces=true:检查类型实现的所有接口,并检查接口之间的继承关系
126+
/// Checks whether a type implements the specified interface.
127+
/// This method is used to check if a concrete type implements a target interface.
128+
///
129+
/// Usage scenarios:
130+
/// 1. In reflection to determine if a type can be used for a specific interface implementation
131+
/// 2. In dependency injection scenarios to validate service implementation
132+
/// 3. In plugin systems to check if a plugin type meets requirements
133+
///
134+
/// Parameter combinations:
135+
/// - directOnly=true, checkIndirectInterfaces=false: Only check directly implemented interfaces
136+
/// - directOnly=false, checkIndirectInterfaces=false: Check all implemented interfaces without checking interface inheritance
137+
/// - directOnly=false, checkIndirectInterfaces=true: Check all implemented interfaces and interface inheritance
149138
/// </remarks>
150-
/// <exception cref="ArgumentNullException">当<paramref name="self"/>或<paramref name="target"/>为null时抛出</exception>
151-
/// <exception cref="ArgumentException">当<paramref name="target"/>不是接口类型时抛出</exception>
139+
/// <param name="self">要判断的类型。必须是非空的具体类型 / The type to check. Must be a non-null concrete type.</param>
140+
/// <param name="target">要判断的接口类型。必须是非空的接口类型 / The interface type to check for. Must be a non-null interface type.</param>
141+
/// <param name="directOnly">是否只检查直接实现的接口,不检查继承的接口 / Whether to only check directly implemented interfaces without checking inherited interfaces.</param>
142+
/// <param name="checkIndirectInterfaces">是否检查接口之间的继承关系 / Whether to check inheritance relationships between interfaces.</param>
143+
/// <returns>如果self实现了target接口,则返回true;否则返回false / true if self implements the target interface; otherwise, false.</returns>
144+
/// <exception cref="ArgumentNullException">当 <paramref name="self"/> 或 <paramref name="target"/> 为 null 时抛出 / Thrown when <paramref name="self"/> or <paramref name="target"/> is null.</exception>
145+
/// <exception cref="ArgumentException">当 <paramref name="target"/> 不是接口类型时抛出 / Thrown when <paramref name="target"/> is not an interface type.</exception>
152146
public static bool IsImplWithInterface(this Type self, Type target, bool directOnly = false, bool checkIndirectInterfaces = true)
153147
{
154148
// 参数有效性检查

0 commit comments

Comments
 (0)