/// <summary> /// Add a given argument key-value pair /// </summary> /// <param name="argumentKey">The type of argument to add</param> /// <param name="argumentValue">The value of the argument to add</param> /// <returns>Previous argument value if any, otherwise null</returns> private string AddArgument(PossibleArgument argumentKey, string argumentValue) { Contract.Ensures(this.programArguments.ContainsKey(argumentKey)); // Special case -- there is a default value for save-location but should only // be set if and only if the option is supplied with no value. if (argumentKey == PossibleArgument.save_program && argumentValue == null) { argumentValue = CeleriacArgs.DefaultSaveProgramLocation; } string oldVal = null; if (this.programArguments.ContainsKey(argumentKey)) { this.programArguments.TryGetValue(argumentKey, out oldVal); this.programArguments.Remove(argumentKey); } this.programArguments.Add(argumentKey, argumentValue); return(oldVal); }
/// <summary> /// Tries to get the value of the given program argument /// </summary> /// <param name="possibleArg">The program to get the argument of</param> /// <param name="value">The value of the argument if it exists, otherwise null</param> /// <returns>The argument's value if it has been specified, otherwise null</returns> private bool TryGetArgumentValue(PossibleArgument possibleArg, out string value) { return(this.programArguments.TryGetValue(possibleArg, out value)); }
/// <summary> /// Whether the given argument was specified /// </summary> /// <param name="possibleArg">The argument type to check</param> /// <returns>True if the argument was specified, otherwise false</returns> private bool IsArgumentSpecified(PossibleArgument possibleArg) { return(this.programArguments.ContainsKey(possibleArg)); }