Skip to content

Commit c0cd97a

Browse files
committed
docs(utility): 为 EnvironmentHelper 和 RuntimePlatformHelper 添加双语文档注释
1 parent 59d8b80 commit c0cd97a

2 files changed

Lines changed: 64 additions & 64 deletions

File tree

GameFrameX.Foundation.Utility/EnvironmentHelper.cs

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -34,43 +34,53 @@
3434
namespace GameFrameX.Foundation.Utility;
3535

3636
/// <summary>
37-
/// Environment helper utility class.
37+
/// 环境帮助器工具类。
3838
/// </summary>
3939
/// <remarks>
40-
/// 环境帮助器
40+
/// Environment helper utility class that provides methods to detect the current runtime environment.
4141
/// </remarks>
4242
public static class EnvironmentHelper
4343
{
44+
/// <summary>
45+
/// 定义标准环境名称常量。
46+
/// </summary>
47+
/// <remarks>
48+
/// Defines standard environment name constants.
49+
/// </remarks>
4450
static class Environments
4551
{
4652
/// <summary>
47-
/// Specifies the Development environment.
53+
/// 指定开发环境。
4854
/// </summary>
49-
/// <remarks>The development environment can enable features that shouldn't be exposed in production. Because of the performance cost, scope validation and dependency validation only happens in development.</remarks>
55+
/// <remarks>
56+
/// Specifies the Development environment. The development environment can enable features that shouldn't be exposed in production. Because of the performance cost, scope validation and dependency validation only happens in development.
57+
/// </remarks>
5058
public static readonly string Development = "Development";
5159

5260
/// <summary>
53-
/// Specifies the Staging environment.
61+
/// 指定预发布环境。
5462
/// </summary>
55-
/// <remarks>The staging environment can be used to validate app changes before changing the environment to production.</remarks>
63+
/// <remarks>
64+
/// Specifies the Staging environment. The staging environment can be used to validate app changes before changing the environment to production.
65+
/// </remarks>
5666
public static readonly string Staging = "Staging";
5767

5868
/// <summary>
59-
/// Specifies the Production environment.
69+
/// 指定生产环境。
6070
/// </summary>
61-
/// <remarks>The production environment should be configured to maximize security, performance, and application robustness.</remarks>
71+
/// <remarks>
72+
/// Specifies the Production environment. The production environment should be configured to maximize security, performance, and application robustness.
73+
/// </remarks>
6274
public static readonly string Production = "Production";
6375
}
6476

6577
/// <summary>
66-
/// Determines whether the current environment is a development environment.
67-
/// Checks if the ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT environment variable is set to Development.
78+
/// 判断当前环境是否为开发环境。
6879
/// </summary>
6980
/// <remarks>
70-
/// 判断是否为开发环境
71-
/// 通过检查环境变量 ASPNETCORE_ENVIRONMENT 或 DOTNET_ENVIRONMENT 的值是否为 Development
81+
/// Determines whether the current environment is a development environment by checking if the ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT environment variable is set to Development.
7282
/// </remarks>
73-
/// <returns>True if the current environment is development, otherwise false. / 如果是开发环境返回true,否则返回false</returns>
83+
/// <returns>如果是开发环境则返回 <c>true</c>;否则返回 <c>false</c> / <c>true</c> if the current environment is development; otherwise <c>false</c></returns>
7484
public static bool IsDevelopment()
7585
{
7686
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")
@@ -80,14 +90,12 @@ public static bool IsDevelopment()
8090
}
8191

8292
/// <summary>
83-
/// Determines whether the current environment is a production environment.
84-
/// Checks if the ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT environment variable is set to Production.
93+
/// 判断当前环境是否为生产环境。
8594
/// </summary>
8695
/// <remarks>
87-
/// 判断是否为生产环境
88-
/// 通过检查环境变量 ASPNETCORE_ENVIRONMENT 或 DOTNET_ENVIRONMENT 的值是否为 Production
96+
/// Determines whether the current environment is a production environment by checking if the ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT environment variable is set to Production.
8997
/// </remarks>
90-
/// <returns>True if the current environment is production, otherwise false. / 如果是生产环境返回true,否则返回false</returns>
98+
/// <returns>如果是生产环境则返回 <c>true</c>;否则返回 <c>false</c> / <c>true</c> if the current environment is production; otherwise <c>false</c></returns>
9199
public static bool IsProduction()
92100
{
93101
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")
@@ -97,14 +105,12 @@ public static bool IsProduction()
97105
}
98106

99107
/// <summary>
100-
/// Determines whether the current environment is a staging/testing environment.
101-
/// Checks if the ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT environment variable is set to Staging.
108+
/// 判断当前环境是否为预发布环境。
102109
/// </summary>
103110
/// <remarks>
104-
/// 判断是否为测试/预发布环境
105-
/// 通过检查环境变量 ASPNETCORE_ENVIRONMENT 或 DOTNET_ENVIRONMENT 的值是否为 Staging
111+
/// Determines whether the current environment is a staging/testing environment by checking if the ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT environment variable is set to Staging.
106112
/// </remarks>
107-
/// <returns>True if the current environment is staging, otherwise false. / 如果是测试/预发布环境返回true,否则返回false</returns>
113+
/// <returns>如果是预发布环境则返回 <c>true</c>;否则返回 <c>false</c> / <c>true</c> if the current environment is staging; otherwise <c>false</c></returns>
108114
public static bool IsStaging()
109115
{
110116
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")
@@ -114,15 +120,13 @@ public static bool IsStaging()
114120
}
115121

116122
/// <summary>
117-
/// Determines whether the current environment matches the specified custom environment name.
118-
/// Checks if the ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT environment variable matches the specified environment name.
123+
/// 判断当前环境是否与指定的自定义环境名称匹配。
119124
/// </summary>
120125
/// <remarks>
121-
/// 判断是否为任意自定义环境
122-
/// 通过检查环境变量 ASPNETCORE_ENVIRONMENT 或 DOTNET_ENVIRONMENT 的值是否与指定环境名称匹配
126+
/// Determines whether the current environment matches the specified custom environment name by checking if the ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT environment variable matches the specified environment name.
123127
/// </remarks>
124-
/// <param name="environmentName">The environment name to check. / 要检查的环境名称</param>
125-
/// <returns>True if the current environment matches the specified environment name, otherwise false. / 如果当前环境与指定环境名称匹配返回true,否则返回false</returns>
128+
/// <param name="environmentName">要检查的环境名称 / The environment name to check</param>
129+
/// <returns>如果当前环境与指定环境名称匹配则返回 <c>true</c>;否则返回 <c>false</c> / <c>true</c> if the current environment matches the specified environment name; otherwise <c>false</c></returns>
126130
public static bool IsEnvironment(string environmentName)
127131
{
128132
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")
@@ -132,42 +136,36 @@ public static bool IsEnvironment(string environmentName)
132136
}
133137

134138
/// <summary>
135-
/// Determines whether the current application is running in a Docker container.
136-
/// Checks if the DOTNET_RUNNING_IN_CONTAINER environment variable exists.
139+
/// 判断当前应用是否运行在 Docker 容器中。
137140
/// </summary>
138141
/// <remarks>
139-
/// 判断当前应用是否运行在Docker容器中
140-
/// 通过检查环境变量 DOTNET_RUNNING_IN_CONTAINER 是否存在来判断
142+
/// Determines whether the current application is running in a Docker container by checking if the DOTNET_RUNNING_IN_CONTAINER environment variable exists.
141143
/// </remarks>
142-
/// <returns>True if running in a Docker container, otherwise false. / 如果在Docker容器中运行返回true,否则返回false</returns>
144+
/// <returns>如果在 Docker 容器中运行则返回 <c>true</c>;否则返回 <c>false</c> / <c>true</c> if running in a Docker container; otherwise <c>false</c></returns>
143145
public static bool IsDocker()
144146
{
145147
return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER"));
146148
}
147149

148150
/// <summary>
149-
/// Determines whether the current application is running in a Kubernetes cluster.
150-
/// Checks if the KUBERNETES_SERVICE_HOST environment variable exists.
151+
/// 判断当前应用是否运行在 Kubernetes 集群中。
151152
/// </summary>
152153
/// <remarks>
153-
/// 判断当前应用是否运行在Kubernetes集群中
154-
/// 通过检查环境变量 KUBERNETES_SERVICE_HOST 是否存在来判断
154+
/// Determines whether the current application is running in a Kubernetes cluster by checking if the KUBERNETES_SERVICE_HOST environment variable exists.
155155
/// </remarks>
156-
/// <returns>True if running in a Kubernetes cluster, otherwise false. / 如果在Kubernetes集群中运行返回true,否则返回false</returns>
156+
/// <returns>如果在 Kubernetes 集群中运行则返回 <c>true</c>;否则返回 <c>false</c> / <c>true</c> if running in a Kubernetes cluster; otherwise <c>false</c></returns>
157157
public static bool IsKubernetes()
158158
{
159159
return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("KUBERNETES_SERVICE_HOST"));
160160
}
161161

162162
/// <summary>
163-
/// Gets the current environment name from environment variables.
164-
/// Returns the value of ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT, or "Production" if neither is set.
163+
/// 获取当前环境名称。
165164
/// </summary>
166165
/// <remarks>
167-
/// 获取当前环境名称
168-
/// 从环境变量 ASPNETCORE_ENVIRONMENT 或 DOTNET_ENVIRONMENT 中获取,如果都未设置则返回 "Production"
166+
/// Gets the current environment name from environment variables. Returns the value of ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT, or <c>null</c> if neither is set.
169167
/// </remarks>
170-
/// <returns>The current environment name. / 当前环境名称</returns>
168+
/// <returns>当前环境名称,如果未设置则返回 <c>null</c> / The current environment name, or <c>null</c> if not set</returns>
171169
public static string GetEnvironmentName()
172170
{
173171
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")

GameFrameX.Foundation.Utility/RuntimePlatformHelper.cs

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,10 @@
3636
namespace GameFrameX.Foundation.Utility;
3737

3838
/// <summary>
39-
/// 平台运行时帮助类
40-
/// Runtime platform helper that detects the current operating system.
39+
/// 平台运行时帮助类,用于检测当前操作系统。
4140
/// </summary>
4241
/// <remarks>
43-
/// Provides simple boolean properties to query Linux, macOS (OSX), Windows, and FreeBSD.
44-
/// Values are evaluated via <see cref="System.Runtime.InteropServices.RuntimeInformation"/> with <see cref="System.Runtime.InteropServices.OSPlatform"/>.
42+
/// Runtime platform helper that detects the current operating system. Provides simple boolean properties to query Linux, macOS (OSX), Windows, and FreeBSD. Values are evaluated via <see cref="System.Runtime.InteropServices.RuntimeInformation"/> with <see cref="System.Runtime.InteropServices.OSPlatform"/>.
4543
/// </remarks>
4644
/// <example>
4745
/// <code>
@@ -60,11 +58,12 @@ namespace GameFrameX.Foundation.Utility;
6058
public static class RuntimePlatformHelper
6159
{
6260
/// <summary>
63-
/// 是否是Linux
64-
/// Indicates whether the current OS is Linux.
61+
/// 获取当前操作系统是否为 Linux。
6562
/// </summary>
66-
/// <value>Returns <c>true</c> when running on Linux; otherwise <c>false</c>.</value>
67-
/// <remarks>Computed from <see cref="System.Runtime.InteropServices.RuntimeInformation"/> using <see cref="System.Runtime.InteropServices.OSPlatform.Linux"/>. This property is read-only.</remarks>
63+
/// <remarks>
64+
/// Indicates whether the current OS is Linux. Computed from <see cref="System.Runtime.InteropServices.RuntimeInformation"/> using <see cref="System.Runtime.InteropServices.OSPlatform.Linux"/>.
65+
/// </remarks>
66+
/// <value>如果运行在 Linux 上则返回 <c>true</c>;否则返回 <c>false</c> / <c>true</c> if running on Linux; otherwise <c>false</c></value>
6867
/// <example>
6968
/// <code>
7069
/// bool onLinux = RuntimePlatformHelper.IsLinux;
@@ -77,11 +76,12 @@ public static bool IsLinux
7776
}
7877

7978
/// <summary>
80-
/// 是否是Mac
81-
/// Indicates whether the current OS is macOS (OSX).
79+
/// 获取当前操作系统是否为 macOS (OSX)。
8280
/// </summary>
83-
/// <value>Returns <c>true</c> when running on macOS; otherwise <c>false</c>.</value>
84-
/// <remarks>Computed from <see cref="System.Runtime.InteropServices.RuntimeInformation"/> using <see cref="System.Runtime.InteropServices.OSPlatform.OSX"/>. This property is read-only.</remarks>
81+
/// <remarks>
82+
/// Indicates whether the current OS is macOS (OSX). Computed from <see cref="System.Runtime.InteropServices.RuntimeInformation"/> using <see cref="System.Runtime.InteropServices.OSPlatform.OSX"/>.
83+
/// </remarks>
84+
/// <value>如果运行在 macOS 上则返回 <c>true</c>;否则返回 <c>false</c> / <c>true</c> if running on macOS; otherwise <c>false</c></value>
8585
/// <example>
8686
/// <code>
8787
/// if (RuntimePlatformHelper.IsOsx)
@@ -97,11 +97,12 @@ public static bool IsOsx
9797
}
9898

9999
/// <summary>
100-
/// 是否是Windows
101-
/// Indicates whether the current OS is Windows.
100+
/// 获取当前操作系统是否为 Windows。
102101
/// </summary>
103-
/// <value>Returns <c>true</c> when running on Windows; otherwise <c>false</c>.</value>
104-
/// <remarks>Computed from <see cref="System.Runtime.InteropServices.RuntimeInformation"/> using <see cref="System.Runtime.InteropServices.OSPlatform.Windows"/>. This property is read-only.</remarks>
102+
/// <remarks>
103+
/// Indicates whether the current OS is Windows. Computed from <see cref="System.Runtime.InteropServices.RuntimeInformation"/> using <see cref="System.Runtime.InteropServices.OSPlatform.Windows"/>.
104+
/// </remarks>
105+
/// <value>如果运行在 Windows 上则返回 <c>true</c>;否则返回 <c>false</c> / <c>true</c> if running on Windows; otherwise <c>false</c></value>
105106
/// <example>
106107
/// <code>
107108
/// if (RuntimePlatformHelper.IsWindows)
@@ -117,11 +118,12 @@ public static bool IsWindows
117118
}
118119

119120
/// <summary>
120-
/// 是否是FreeBSD
121-
/// Indicates whether the current OS is FreeBSD.
121+
/// 获取当前操作系统是否为 FreeBSD。
122122
/// </summary>
123-
/// <value>Returns <c>true</c> when running on FreeBSD; otherwise <c>false</c>.</value>
124-
/// <remarks>Computed from <see cref="System.Runtime.InteropServices.RuntimeInformation"/> using <see cref="System.Runtime.InteropServices.OSPlatform.FreeBSD"/>. This property is read-only.</remarks>
123+
/// <remarks>
124+
/// Indicates whether the current OS is FreeBSD. Computed from <see cref="System.Runtime.InteropServices.RuntimeInformation"/> using <see cref="System.Runtime.InteropServices.OSPlatform.FreeBSD"/>.
125+
/// </remarks>
126+
/// <value>如果运行在 FreeBSD 上则返回 <c>true</c>;否则返回 <c>false</c> / <c>true</c> if running on FreeBSD; otherwise <c>false</c></value>
125127
/// <example>
126128
/// <code>
127129
/// bool onBsd = RuntimePlatformHelper.IsFreeBsd;

0 commit comments

Comments
 (0)