public void ResolveArguments() { var method = Pipeline.CommandMethods[NormalizedCommandName]; if (method.GetCustomAttributes(typeof(DoNotResolveVariablesAttribute), false).Any()) { // We're not resolving attributes for this method. Bail out... return; } // This is a whole lot of crap to get around the problem of modifying a collection while it's being iterated... var variablesToResolve = new Dictionary <object, string>(); foreach (var commandArg in CommandArgs) { if (PipelineCommandParser.IsVariableName(commandArg.Value)) { variablesToResolve.Add(commandArg.Key, commandArg.Value); } } foreach (var variable in variablesToResolve) { CommandArgs[variable.Key] = Pipeline.GetVariable(PipelineCommandParser.NormalizeVariableName(variable.Value)).ToString(); } }
public object GetVariable(string key, bool checkGlobal = false) { key = PipelineCommandParser.NormalizeVariableName(key); // See important comment at declaration above var variableRetrievingEvents = new VariableEventArgs(this, key); OnVariableRetrieving(variableRetrievingEvents); key = variableRetrievingEvents.Key; if (!variables.ContainsKey(key)) { if (checkGlobal) { if (IsSetGlobally(key)) { return(GetGlobalVariable(key)); } } throw new DeninaException(string.Format("Attempt to access non-existent variable: \"{0}\"", key)); } var value = variables[PipelineCommandParser.NormalizeVariableName(key)].Value; // See important comment at declaration above var variableRetrievedEvents = new VariableEventArgs(this, key, value); OnVariableRetrieved(variableRetrievedEvents); value = variableRetrievedEvents.Value; return(value ?? string.Empty); }
public static object GetGlobalVariable(string key) { key = PipelineCommandParser.NormalizeVariableName(key); if (!globalVariables.ContainsKey(key)) { throw new DeninaException(string.Format("Attempt to access non-existent variable: \"{0}\"", key)); } return(globalVariables[PipelineCommandParser.NormalizeVariableName(key)].Value); }
public static void SetGlobalVariable(string key, object value, bool readOnly = false) { key = PipelineCommandParser.NormalizeVariableName(key); globalVariables.Remove(key); globalVariables.Add( key, new PipelineVariable( key, value, readOnly ) ); }
public object GetVariable(string key, bool checkGlobal = false) { key = PipelineCommandParser.NormalizeVariableName(key); if (!variables.ContainsKey(key)) { if (checkGlobal) { if (IsSetGlobally(key)) { return(GetGlobalVariable(key)); } } throw new DeninaException(string.Format("Attempt to access non-existent variable: \"{0}\"", key)); } return(variables[PipelineCommandParser.NormalizeVariableName(key)].Value ?? string.Empty); }
public void AddCommand(string commandString) { commands.AddRange(PipelineCommandParser.ParseCommandString(commandString)); }