示例#1
0
        public static bool ResolveEnvironmentVariables(IEnvironmentVariableContext context, StringBuilder resultBuilder, Action<string> failLog = null)
        {
            Match match;
            do
            {
                match = envVarsRegex.Match(resultBuilder.ToString());

                if (match.Success)
                {
                    string value = context.GetEnvironmentVariable(match.Groups[1].Captures[0].Value);
                    if (value == null)
                    {
                        if (failLog != null)
                            failLog(match.Value);
                        return false;
                    }
                    else
                    {
                        resultBuilder.Remove(match.Index, match.Length);
                        resultBuilder.Insert(match.Index, value);
                    }
                }
            } while (match.Success);

            return true;
        }
示例#2
0
        public static bool ResolveEnvironmentVariables(IEnvironmentVariableContext context, StringBuilder resultBuilder, Action <string> failLog = null)
        {
            Match match;

            do
            {
                match = envVarsRegex.Match(resultBuilder.ToString());

                if (match.Success)
                {
                    string value = context.GetEnvironmentVariable(match.Groups[1].Captures[0].Value);
                    if (value == null)
                    {
                        if (failLog != null)
                        {
                            failLog(match.Value);
                        }
                        return(false);
                    }
                    else
                    {
                        resultBuilder.Remove(match.Index, match.Length);
                        resultBuilder.Insert(match.Index, value);
                    }
                }
            } while (match.Success);

            return(true);
        }
示例#3
0
        public string GetEnvironmentVariable(string name)
        {
            var result = baseImpl.GetEnvironmentVariable(name);

            if (String.IsNullOrWhiteSpace(result))
            {
                return("0");
            }
            else
            {
                return(result);
            }
        }
示例#4
0
 public string GetEnvironmentVariable(string name)
 {
     return(environmentVariableContext.GetEnvironmentVariable(name));
 }