public string ExpandVariables(Dictionary <string, string> variables, string action) { var finalVariables = ExpandVariablesInVariables(variables); foreach (var(key, value) in finalVariables) { action = action.Replace($"$({key})", value); } // expand environment variables var matches = Regex.Matches(action, "\\$\\{(?<name>.+?)\\}"); foreach (Match match in matches) { if (match.Success) { var envVarName = match.Groups["name"]?.Value; var envVarValue = _environmentVariableProvider.Get(envVarName); if (!string.IsNullOrWhiteSpace(envVarValue)) { action = action.Replace($"${{{envVarName}}}", envVarValue); } } } return(action); }
public override void Load() { var data = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); foreach (var i in _environmentVariableNameToKeyMapping) { string value = _environmentVariableProvider.Get(i.Key, _environmentVariableTarget); if (!string.IsNullOrEmpty(value)) { data[i.Value] = value; } } Data = data; }