Esempio n. 1
0
        /// <summary>
        /// Converts the boolean to an equivalent yes/no string expression.
        /// </summary>
        /// <param name="value">Value to convert.</param>
        /// <param name="pattern">The pattern of capitalization to use.</param>
        /// <returns>string.</returns>
        public static string StringifyYesNo(this bool value,
                                            eCapitalization pattern = eCapitalization.alllower)
        {
            string stringified = value ? "yes" : "no";

            return(stringified.Capitalize(pattern));
        }
Esempio n. 2
0
        /// <summary>
        /// Converts the boolean to an equivalent string expression.
        /// </summary>
        /// <param name="value">Value to convert.</param>
        /// <param name="pattern">The pattern of capitalization to use.</param>
        /// <returns>string.</returns>
        public static string Stringify(this bool value,
                                       eCapitalization pattern = eCapitalization.alllower)
        {
            string stringified = value ? "true" : "false";

            return(stringified.Capitalize(pattern));
        }
Esempio n. 3
0
        /// <summary>
        /// Converts a string to the specified capitalization pattern.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="pattern">The pattern to capitalize by.</param>
        /// <returns>string.</returns>
        public static string Capitalize(this string value,
                                        eCapitalization pattern)
        {
            if (string.IsNullOrWhiteSpace(value))
            {
                return(string.Empty);
            }
            switch (pattern)
            {
            case eCapitalization.alllower:
                return(value.ToLower());

            case eCapitalization.ALLCAPS:
                return(value.ToUpper());

            case eCapitalization.Firstupper:
                return(value[0].ToString().ToUpper() + value.Substring(1, value.Length - 1).ToLower());

            default:
                return(value.ToUpper());
            }
        }
 public string Capitalize(string value, eCapitalization capitalization)
 {
     return(value.Capitalize(capitalization));
 }
 public string ConvertTrueTrueString(bool value, eCapitalization capitalization)
 {
     return(ConversionLibrary.ConvertTrueTrueString(value, capitalization));
 }
 public string CapitalizationSingleWord_Returns_Capitalized_String(string value, eCapitalization capitalization)
 {
     return(ConversionLibrary.CapitalizationSingleWord(value, capitalization));
 }
Esempio n. 7
0
 /// <summary>
 /// Converts the nullable boolean to an equivalent yes/no/{unknown} string expression.
 /// </summary>
 /// <param name="value">Value to convert.</param>
 /// <param name="forNull">Value to return if null.</param>
 /// <param name="pattern">The pattern of capitalization to use.</param>
 /// <returns>string.</returns>
 public static string StringifyYesNo(this bool?value,
                                     string forNull          = "null",
                                     eCapitalization pattern = eCapitalization.alllower)
 {
     return(value == null?forNull.Capitalize(pattern) : StringifyYesNo((bool)value));
 }
 public string StringifyYesNoNullable(bool?value, eCapitalization capitalization, string forNull = "")
 {
     return(value.StringifyYesNo(forNull: forNull, pattern: capitalization));
 }
 public string Stringify(bool value, eCapitalization capitalization)
 {
     return(value.Stringify(capitalization));
 }
Esempio n. 10
0
 public string StringifyNullable(bool?value, eCapitalization capitalization, string forNull = "Unknown")
 {
     return(value.Stringify(forNull: forNull, pattern: capitalization));
 }