Exemple #1
0
        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();
            }
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
 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
             )
         );
 }
Exemple #5
0
        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);
        }
Exemple #6
0
 public void AddCommand(string commandString)
 {
     commands.AddRange(PipelineCommandParser.ParseCommandString(commandString));
 }