public static string GetSummary()

in src/DeloitteDigital.Atlas/Extensions/StringExtensions.cs [100:124]


        public static string GetSummary(this string str, int length, string addString)
        {
            // rid of characters which will break stuff
            str = str.Replace("\n", "");
            str = str.Replace("\r", "");
            str = str.Replace("\t", "");

            // clean up any leading or whitespace.
            str = RemoveTags(str.Trim());

            if (str.Length > length)
            {
                // if string is null or empty return empty string.
                if (string.IsNullOrEmpty(str)) return "";

                // otherwise generate the summary.
                str = Regex.Match(str, @"^.{1," + length + @"}\b(?<!\s)").Value;
            }

            // throw the append string on no matter what... looks better being consistant.
            if (!string.IsNullOrEmpty(str) && !string.IsNullOrEmpty(addString))
                str = str.TrimEnd('.') + addString;

            return str;
        }