Assets/Watson/Scripts/Utilities/Config.cs
/// <summary>
/// Resolves any variables found in the input string and returns the variable values in the returned string.
/// </summary>
/// <param name="input">A string containing variables.</param>
/// <returns>Returns the string with all variables resolved to their actual values. Any missing variables are removed from the string.</returns>
Resolves any variables found in the input string and returns the variable values in the returned string.
Resolves any variables found in the input string and returns the variable values in the returned string .
public string ResolveVariables(string input, bool recursive = true)
        {
            string output = input;
            foreach (var var in m_Variables)
            {
                string value = var.Value;
                if (recursive && value.Contains("${"))
                    value = ResolveVariables(value, false);
                output = output.Replace("${" + var.Key + "}", value);
            }
            int variableIndex = output.IndexOf("${");
            while (variableIndex >= 0)
            {
                int endVariable = output.IndexOf("}", variableIndex);
                if (endVariable < 0)
                    break;      
                output = output.Remove(variableIndex, (endVariable - variableIndex) + 1);
                variableIndex = output.IndexOf("${");
            }
            return output;
        }
public string ResolveVariables ( string input , bool recursive = true ) { string output = input ; foreach ( var var in m_Variables ) { string value = var . Value ; if ( recursive && value . Contains ( " " ) ) value = ResolveVariables ( value , false ) ; output = output . Replace ( " " + var . Key + " " , value ) ; } int variableIndex = output . IndexOf ( " " ) ; while ( variableIndex >= 0 ) { int endVariable = output . IndexOf ( " " , variableIndex ) ; if ( endVariable < 0 ) break ; output = output . Remove ( variableIndex , ( endVariable - variableIndex ) + 1 ) ; variableIndex = output . IndexOf ( " " ) ; } return output ; }
Resolves any variables found in the input string and returns the variable values in the returned string.
Resolves any variables found in the input string and returns the variable values in the returned string .
// remove any variables still in the string.. // end not found.. // next..
Returns the string with all variables resolved to their actual values. Any missing variables are removed from the string.
Returns the string with all variables resolved to their actual values . Any missing variables are removed from the string .
input
string
A string containing variables.
A string containing variables .
recursive
bool