/// <summary> /// Converts a parameter to an boolean /// </summary> /// <param name="index">Index of parameter to convert</param> /// <returns></returns> public bool ToBoolean(int index) { bool?v = ConConverter.ToBool(this[index]); if (!v.HasValue) { Command.ThrowArgumentError(this[index], new string[] { "true", "false" }, ErrorCode.NOT_BOOLEAN); throw new InvalidCastException("NaN"); } return(v.Value); }
/// <summary> /// Checks whether an argument can be represented as a boolean /// </summary> /// <param name="index">Index of parameter to check</param> /// <returns></returns> public bool IsBoolean(int index) { return(ConConverter.ToBool(this[index]).HasValue); }