Skip to content

Commit f37bed4

Browse files
committed
docs(Utility): 完善环境帮助类的文档注释
更新EnvironmentHelper类的文档注释,添加英文描述并保持原有中文注释 统一方法返回值的描述格式,增加方法功能的详细说明
1 parent e37f353 commit f37bed4

File tree

1 file changed

+48
-17
lines changed

1 file changed

+48
-17
lines changed

GameFrameX.Utility/EnvironmentHelper.cs

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,22 @@
3636
namespace GameFrameX.Utility;
3737

3838
/// <summary>
39-
/// 环境帮助器
39+
/// Environment helper utility class.
4040
/// </summary>
41+
/// <remarks>
42+
/// 环境帮助器
43+
/// </remarks>
4144
public static class EnvironmentHelper
4245
{
4346
/// <summary>
47+
/// Determines whether the current environment is a development environment.
48+
/// Checks if the ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT environment variable is set to Development.
49+
/// </summary>
50+
/// <remarks>
4451
/// 判断是否为开发环境
4552
/// 通过检查环境变量 ASPNETCORE_ENVIRONMENT 或 DOTNET_ENVIRONMENT 的值是否为 Development
46-
/// </summary>
47-
/// <returns>如果是开发环境返回true,否则返回false</returns>
53+
/// </remarks>
54+
/// <returns>True if the current environment is development, otherwise false. / 如果是开发环境返回true,否则返回false</returns>
4855
public static bool IsDevelopment()
4956
{
5057
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")
@@ -54,10 +61,14 @@ public static bool IsDevelopment()
5461
}
5562

5663
/// <summary>
64+
/// Determines whether the current environment is a production environment.
65+
/// Checks if the ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT environment variable is set to Production.
66+
/// </summary>
67+
/// <remarks>
5768
/// 判断是否为生产环境
5869
/// 通过检查环境变量 ASPNETCORE_ENVIRONMENT 或 DOTNET_ENVIRONMENT 的值是否为 Production
59-
/// </summary>
60-
/// <returns>如果是生产环境返回true,否则返回false</returns>
70+
/// </remarks>
71+
/// <returns>True if the current environment is production, otherwise false. / 如果是生产环境返回true,否则返回false</returns>
6172
public static bool IsProduction()
6273
{
6374
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")
@@ -67,10 +78,14 @@ public static bool IsProduction()
6778
}
6879

6980
/// <summary>
81+
/// Determines whether the current environment is a staging/testing environment.
82+
/// Checks if the ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT environment variable is set to Staging.
83+
/// </summary>
84+
/// <remarks>
7085
/// 判断是否为测试/预发布环境
7186
/// 通过检查环境变量 ASPNETCORE_ENVIRONMENT 或 DOTNET_ENVIRONMENT 的值是否为 Staging
72-
/// </summary>
73-
/// <returns>如果是测试/预发布环境返回true,否则返回false</returns>
87+
/// </remarks>
88+
/// <returns>True if the current environment is staging, otherwise false. / 如果是测试/预发布环境返回true,否则返回false</returns>
7489
public static bool IsStaging()
7590
{
7691
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")
@@ -80,11 +95,15 @@ public static bool IsStaging()
8095
}
8196

8297
/// <summary>
98+
/// Determines whether the current environment matches the specified custom environment name.
99+
/// Checks if the ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT environment variable matches the specified environment name.
100+
/// </summary>
101+
/// <remarks>
83102
/// 判断是否为任意自定义环境
84103
/// 通过检查环境变量 ASPNETCORE_ENVIRONMENT 或 DOTNET_ENVIRONMENT 的值是否与指定环境名称匹配
85-
/// </summary>
86-
/// <param name="environmentName">要检查的环境名称</param>
87-
/// <returns>如果当前环境与指定环境名称匹配返回true,否则返回false</returns>
104+
/// </remarks>
105+
/// <param name="environmentName">The environment name to check. / 要检查的环境名称</param>
106+
/// <returns>True if the current environment matches the specified environment name, otherwise false. / 如果当前环境与指定环境名称匹配返回true,否则返回false</returns>
88107
public static bool IsEnvironment(string environmentName)
89108
{
90109
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")
@@ -94,30 +113,42 @@ public static bool IsEnvironment(string environmentName)
94113
}
95114

96115
/// <summary>
116+
/// Determines whether the current application is running in a Docker container.
117+
/// Checks if the DOTNET_RUNNING_IN_CONTAINER environment variable exists.
118+
/// </summary>
119+
/// <remarks>
97120
/// 判断当前应用是否运行在Docker容器中
98121
/// 通过检查环境变量 DOTNET_RUNNING_IN_CONTAINER 是否存在来判断
99-
/// </summary>
100-
/// <returns>如果在Docker容器中运行返回true,否则返回false</returns>
122+
/// </remarks>
123+
/// <returns>True if running in a Docker container, otherwise false. / 如果在Docker容器中运行返回true,否则返回false</returns>
101124
public static bool IsDocker()
102125
{
103126
return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER"));
104127
}
105128

106129
/// <summary>
130+
/// Determines whether the current application is running in a Kubernetes cluster.
131+
/// Checks if the KUBERNETES_SERVICE_HOST environment variable exists.
132+
/// </summary>
133+
/// <remarks>
107134
/// 判断当前应用是否运行在Kubernetes集群中
108135
/// 通过检查环境变量 KUBERNETES_SERVICE_HOST 是否存在来判断
109-
/// </summary>
110-
/// <returns>如果在Kubernetes集群中运行返回true,否则返回false</returns>
136+
/// </remarks>
137+
/// <returns>True if running in a Kubernetes cluster, otherwise false. / 如果在Kubernetes集群中运行返回true,否则返回false</returns>
111138
public static bool IsKubernetes()
112139
{
113140
return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("KUBERNETES_SERVICE_HOST"));
114141
}
115142

116143
/// <summary>
117-
/// 获取当前运行环境名称
118-
/// 优先获取 ASPNETCORE_ENVIRONMENT 环境变量,如果不存在则获取 DOTNET_ENVIRONMENT 环境变量
144+
/// Gets the current environment name from environment variables.
145+
/// Returns the value of ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT, or "Production" if neither is set.
119146
/// </summary>
120-
/// <returns>返回当前环境名称,如果未设置环境变量则返回null</returns>
147+
/// <remarks>
148+
/// 获取当前环境名称
149+
/// 从环境变量 ASPNETCORE_ENVIRONMENT 或 DOTNET_ENVIRONMENT 中获取,如果都未设置则返回 "Production"
150+
/// </remarks>
151+
/// <returns>The current environment name. / 当前环境名称</returns>
121152
public static string GetEnvironmentName()
122153
{
123154
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")

0 commit comments

Comments
 (0)