Exemple #1
0
        /// <summary>
        /// Denulls the string and converts <br> line breaks into c# line breaks />
        /// </summary>
        public static string HtmlLineBreaksToCSharp(this string input)
        {
            input = GeneralHelper.DenullString(input);

            input = input.Replace("<br />", Environment.NewLine);
            input = input.Replace("<br/>", Environment.NewLine);
            input = input.Replace("<br>", Environment.NewLine);

            return(input);
        }
Exemple #2
0
        /// <summary>
        /// Denulls the string and converts line breaks into <br />
        /// </summary>
        public static string LineBreaksToHtml(this string input)
        {
            input = GeneralHelper.DenullString(input);

            input = input.Replace(Environment.NewLine, "<br />");

            //In case there are any line breaks without carriage returns, replace "\n" as well

            input = input.Replace("\n", "<br />");

            return(input);
        }
Exemple #3
0
        /// <summary>
        /// Converts a Y / N to true / false, returning Null if Y or N not passed in
        /// </summary>
        public static bool?YNStringToNullableBool(this string input)
        {
            bool?output = null;

            var str = GeneralHelper.DenullString(input);

            if (str.ToUpper() == "Y")
            {
                output = true;
            }
            else if (str.ToUpper() == "N")
            {
                output = false;
            }

            return(output);
        }
Exemple #4
0
        /// <summary>
        /// Converts a Yes / No to true / false, returning False if Null or empty string passed in, and throwing an exception if anything else was passed in.
        /// </summary>
        public static bool YesNoStringToBool(this string input)
        {
            bool output = false;

            var str = GeneralHelper.DenullString(input);

            if (str.ToUpper() == "YES")
            {
                output = true;
            }
            else if (str.ToUpper() == "NO" || str == "")
            {
                output = false;
            }
            else
            {
                throw new Exception("Invalid Input String");
            }

            return(output);
        }
Exemple #5
0
 /// <summary>
 /// Returns the string value that was passed in, or an empty string if the value was null
 /// </summary>
 public static string NullToEmptyString(this string input)
 {
     return(GeneralHelper.DenullString(input));
 }
 /// <summary>
 /// Returns the string value that was passed in, or an empty string if the value was null
 /// </summary>
 public static string NullObjectToEmptyString(this object input)
 {
     return(GeneralHelper.DenullString(input));
 }