Skip to content

Commit

Permalink
优化GetEnvironmentVariable,支持“Environment.GetEnvironmentVariable”的方式获取环…
Browse files Browse the repository at this point in the history
…境变量的值;
  • Loading branch information
zqlovejyc committed Sep 2, 2021
1 parent fc2bce1 commit 5e6fe96
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ZqUtils.Core/Helpers/EnvironmentHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using ZqUtils.Core.Extensions;
/****************************
* [Author] 张强
* [Date] 2019-02-27
Expand All @@ -41,7 +42,7 @@ public static string GetEnvironmentVariable(string value)
{
var result = value;
var param = GetParameters(result).FirstOrDefault();
if (!string.IsNullOrEmpty(param))
if (param.IsNotNullOrEmpty())
{
var env = Environment.GetEnvironmentVariable(param);
result = env;
Expand All @@ -51,6 +52,11 @@ public static string GetEnvironmentVariable(string value)
result = arrayData.Length == 2 ? arrayData[1] : env;
}
}
else
{
result = Environment.GetEnvironmentVariable(value);
}

return result;
}

Expand Down

0 comments on commit 5e6fe96

Please sign in to comment.