Esempio n. 1
0
        /// <summary>
        /// Sets a variable to an boolean value.
        /// </summary>
        /// <param name="name">The case sensitive variable name.</param>
        /// <param name="value">The option value.</param>
        /// <remarks>
        /// <note>
        /// The value set will be lower case <b>true</b> or <b>false</b>.
        /// </note>
        /// </remarks>
        public void Set(string name, bool value)
        {
            Covenant.Requires <ArgumentNullException>(!string.IsNullOrWhiteSpace(name));
            Covenant.Requires <ArgumentException>(VariableValidationRegex.IsMatch(name));

            variables[name] = value ? "true" : "false";
        }
Esempio n. 2
0
        /// <summary>
        /// Sets a variable to an boolean value.
        /// </summary>
        /// <param name="name">The case sensitive variable name.</param>
        /// <param name="value">The option value.</param>
        /// <remarks>
        /// <note>
        /// The value set will be lower case <b>true</b> or <b>false</b>.
        /// </note>
        /// </remarks>
        public void Set(string name, bool value)
        {
            Covenant.Requires <ArgumentNullException>(!string.IsNullOrWhiteSpace(name), nameof(name));
            Covenant.Requires <ArgumentException>(VariableValidationRegex.IsMatch(name), nameof(name));

            variables[name] = NeonHelper.ToBoolString(value);
        }
Esempio n. 3
0
        /// <summary>
        /// Sets a variable to an object value.
        /// </summary>
        /// <param name="name">The case sensitive variable name.</param>
        /// <param name="value">The option value (defaults to the null).</param>
        public void Set(string name, object value = null)
        {
            Covenant.Requires <ArgumentNullException>(!string.IsNullOrWhiteSpace(name));
            Covenant.Requires <ArgumentException>(VariableValidationRegex.IsMatch(name));

            value = value ?? string.Empty;

            variables[name] = value.ToString();
        }
Esempio n. 4
0
        /// <summary>
        /// Sets a variable to a string value.
        /// </summary>
        /// <param name="name">The case sensitive variable name.</param>
        /// <param name="value">The option value (defaults to the empty string).</param>
        public void Set(string name, string value = "")
        {
            Covenant.Requires <ArgumentNullException>(!string.IsNullOrWhiteSpace(name), nameof(name));
            Covenant.Requires <ArgumentException>(VariableValidationRegex.IsMatch(name), nameof(name));

            value = value ?? string.Empty;

            variables[name] = value;
        }