You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: GameFrameX.Foundation.Utility/EnvironmentHelper.cs
+42-44Lines changed: 42 additions & 44 deletions
Original file line number
Diff line number
Diff line change
@@ -34,43 +34,53 @@
34
34
namespaceGameFrameX.Foundation.Utility;
35
35
36
36
/// <summary>
37
-
/// Environment helper utility class.
37
+
/// 环境帮助器工具类。
38
38
/// </summary>
39
39
/// <remarks>
40
-
/// 环境帮助器
40
+
/// Environment helper utility class that provides methods to detect the current runtime environment.
41
41
/// </remarks>
42
42
publicstaticclassEnvironmentHelper
43
43
{
44
+
/// <summary>
45
+
/// 定义标准环境名称常量。
46
+
/// </summary>
47
+
/// <remarks>
48
+
/// Defines standard environment name constants.
49
+
/// </remarks>
44
50
staticclassEnvironments
45
51
{
46
52
/// <summary>
47
-
/// Specifies the Development environment.
53
+
/// 指定开发环境。
48
54
/// </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.
/// <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>
56
66
publicstaticreadonlystringStaging="Staging";
57
67
58
68
/// <summary>
59
-
/// Specifies the Production environment.
69
+
/// 指定生产环境。
60
70
/// </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.
/// 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
+
/// 判断当前环境是否为开发环境。
68
79
/// </summary>
69
80
/// <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.
72
82
/// </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>
@@ -80,14 +90,12 @@ public static bool IsDevelopment()
80
90
}
81
91
82
92
/// <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
+
/// 判断当前环境是否为生产环境。
85
94
/// </summary>
86
95
/// <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.
89
97
/// </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>
/// 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.
106
112
/// </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>
/// 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.
123
127
/// </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>
@@ -132,42 +136,36 @@ public static bool IsEnvironment(string environmentName)
132
136
}
133
137
134
138
/// <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 容器中。
137
140
/// </summary>
138
141
/// <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.
141
143
/// </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>
/// Determines whether the current application is running in a Kubernetes cluster.
150
-
/// Checks if the KUBERNETES_SERVICE_HOST environment variable exists.
151
+
/// 判断当前应用是否运行在 Kubernetes 集群中。
151
152
/// </summary>
152
153
/// <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.
155
155
/// </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>
/// 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.
169
167
/// </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>
Copy file name to clipboardExpand all lines: GameFrameX.Foundation.Utility/RuntimePlatformHelper.cs
+22-20Lines changed: 22 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -36,12 +36,10 @@
36
36
namespaceGameFrameX.Foundation.Utility;
37
37
38
38
/// <summary>
39
-
/// 平台运行时帮助类
40
-
/// Runtime platform helper that detects the current operating system.
39
+
/// 平台运行时帮助类,用于检测当前操作系统。
41
40
/// </summary>
42
41
/// <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"/>.
/// <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>
68
67
/// <example>
69
68
/// <code>
70
69
/// bool onLinux = RuntimePlatformHelper.IsLinux;
@@ -77,11 +76,12 @@ public static bool IsLinux
77
76
}
78
77
79
78
/// <summary>
80
-
/// 是否是Mac
81
-
/// Indicates whether the current OS is macOS (OSX).
79
+
/// 获取当前操作系统是否为 macOS (OSX)。
82
80
/// </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>
85
85
/// <example>
86
86
/// <code>
87
87
/// if (RuntimePlatformHelper.IsOsx)
@@ -97,11 +97,12 @@ public static bool IsOsx
97
97
}
98
98
99
99
/// <summary>
100
-
/// 是否是Windows
101
-
/// Indicates whether the current OS is Windows.
100
+
/// 获取当前操作系统是否为 Windows。
102
101
/// </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>
105
106
/// <example>
106
107
/// <code>
107
108
/// if (RuntimePlatformHelper.IsWindows)
@@ -117,11 +118,12 @@ public static bool IsWindows
117
118
}
118
119
119
120
/// <summary>
120
-
/// 是否是FreeBSD
121
-
/// Indicates whether the current OS is FreeBSD.
121
+
/// 获取当前操作系统是否为 FreeBSD。
122
122
/// </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>
0 commit comments