Ejemplo n.º 1
0
        public static IOperationProvider Setup(IReplacementTokens tokens, IParameterSet parameters)
        {
            ITemplateParameter param;

            if (parameters.TryGetParameterDefinition(tokens.VariableName, out param))
            {
                Replacement replacement;
                try
                {
                    string newValue = (string)(parameters.ResolvedValues[param]);
                    replacement = new Replacement(tokens.OriginalValue, newValue, null);
                }
                catch (KeyNotFoundException ex)
                {
                    throw new Exception($"Unable to find a parameter value called \"{param.Name}\"", ex);
                }

                return(replacement);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
 public static IOperationProvider Setup(IEngineEnvironmentSettings environmentSettings, IReplacementTokens tokens, IParameterSet parameters)
 {
     if (parameters.TryGetRuntimeValue(environmentSettings, tokens.VariableName, out object newValueObject))
     {
         string newValue = newValueObject.ToString();
         return(new Replacement(tokens.OriginalValue, newValue, null, true));
     }
     else
     {
         environmentSettings.Host.LogMessage($"Couldn't find a parameter called {tokens.VariableName}");
         return(null);
     }
 }