Showing the changes to Source/Libraries/GSF.Core.Shared/StringExtensions.cs (1 of 3 files). Show all
Unified · Split
| @@ -221,7 +221,7 @@ namespace GSF · 220 unmodified lines | |||
| 221 | throw new ArgumentNullException(nameof(type)); | 221 | throw new ArgumentNullException(nameof(type)); |
| 222 | 222 | ||
| 223 | // Initialize culture info if not specified. | 223 | // Initialize culture info if not specified. |
| 224 | if ((object)culture == null) | 224 | if (culture == null) |
| 225 | culture = CultureInfo.InvariantCulture; | 225 | culture = CultureInfo.InvariantCulture; |
| 226 | 226 | ||
| 227 | try | 227 | try |
| @@ -332,7 +332,7 @@ namespace GSF · 104 unmodified lines | |||
| 332 | /// </remarks> | 332 | /// </remarks> |
| 333 | public static string JoinKeyValuePairs(this IDictionary<string, string> pairs, char parameterDelimiter = ';', char keyValueDelimiter = '=', char startValueDelimiter = '{', char endValueDelimiter = '}') | 333 | public static string JoinKeyValuePairs(this IDictionary<string, string> pairs, char parameterDelimiter = ';', char keyValueDelimiter = '=', char startValueDelimiter = '{', char endValueDelimiter = '}') |
| 334 | { | 334 | { |
| 335 | if ((object)pairs == null) | 335 | if (pairs == null) |
| 336 | throw new ArgumentNullException(nameof(pairs)); | 336 | throw new ArgumentNullException(nameof(pairs)); |
| 337 | 337 | ||
| 338 | char[] delimiters = { parameterDelimiter, keyValueDelimiter }; | 338 | char[] delimiters = { parameterDelimiter, keyValueDelimiter }; |
| @@ -387,7 +387,7 @@ namespace GSF · 48 unmodified lines | |||
| 387 | [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] | 387 | [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] |
| 388 | public static Dictionary<string, string> ParseKeyValuePairs(this string value, char parameterDelimiter = ';', char keyValueDelimiter = '=', char startValueDelimiter = '{', char endValueDelimiter = '}', bool ignoreDuplicateKeys = true) | 388 | public static Dictionary<string, string> ParseKeyValuePairs(this string value, char parameterDelimiter = ';', char keyValueDelimiter = '=', char startValueDelimiter = '{', char endValueDelimiter = '}', bool ignoreDuplicateKeys = true) |
| 389 | { | 389 | { |
| 390 | if (value == (string)null) | 390 | if (value == null) |
| 391 | throw new ArgumentNullException(nameof(value)); | 391 | throw new ArgumentNullException(nameof(value)); |
| 392 | 392 | ||
| 393 | if (parameterDelimiter == keyValueDelimiter || | 393 | if (parameterDelimiter == keyValueDelimiter || |
| @@ -564,7 +564,7 @@ namespace GSF · 170 unmodified lines | |||
| 564 | public static string ReplaceCharacters(this string value, char replacementCharacter, Func<char, bool> characterTestFunction) | 564 | public static string ReplaceCharacters(this string value, char replacementCharacter, Func<char, bool> characterTestFunction) |
| 565 | { | 565 | { |
| 566 | // <pex> | 566 | // <pex> |
| 567 | if (characterTestFunction == (Func<char, bool>)null) | 567 | if (characterTestFunction == null) |
| 568 | throw new ArgumentNullException(nameof(characterTestFunction)); | 568 | throw new ArgumentNullException(nameof(characterTestFunction)); |
| 569 | // </pex> | 569 | // </pex> |
| 570 | 570 | ||
| @@ -596,7 +596,7 @@ namespace GSF · 25 unmodified lines | |||
| 596 | public static string RemoveCharacters(this string value, Func<char, bool> characterTestFunction) | 596 | public static string RemoveCharacters(this string value, Func<char, bool> characterTestFunction) |
| 597 | { | 597 | { |
| 598 | // <pex> | 598 | // <pex> |
| 599 | if (characterTestFunction == (Func<char, bool>)null) | 599 | if (characterTestFunction == null) |
| 600 | throw new ArgumentNullException(nameof(characterTestFunction)); | 600 | throw new ArgumentNullException(nameof(characterTestFunction)); |
| 601 | // </pex> | 601 | // </pex> |
| 602 | 602 | ||
| @@ -716,7 +716,7 @@ namespace GSF · 113 unmodified lines | |||
| 716 | public static string ReplaceCrLfs(this string value, char replacementCharacter) | 716 | public static string ReplaceCrLfs(this string value, char replacementCharacter) |
| 717 | { | 717 | { |
| 718 | // <pex> | 718 | // <pex> |
| 719 | if (value == (string)null) | 719 | if (value == null) |
| 720 | throw new ArgumentNullException(nameof(value)); | 720 | throw new ArgumentNullException(nameof(value)); |
| 721 | // </pex> | 721 | // </pex> |
| 722 | 722 | ||
| @@ -1092,7 +1092,7 @@ namespace GSF · 369 unmodified lines | |||
| 1092 | public static char RegexDecode(this string value) | 1092 | public static char RegexDecode(this string value) |
| 1093 | { | 1093 | { |
| 1094 | // <pex> | 1094 | // <pex> |
| 1095 | if (value == (string)null) | 1095 | if (value == null) |
| 1096 | throw new ArgumentNullException(nameof(value)); | 1096 | throw new ArgumentNullException(nameof(value)); |
| 1097 | // </pex> | 1097 | // </pex> |
| 1098 | 1098 | ||
| @@ -1164,7 +1164,7 @@ namespace GSF · 65 unmodified lines | |||
| 1164 | { | 1164 | { |
| 1165 | IntPtr intPtr; | 1165 | IntPtr intPtr; |
| 1166 | 1166 | ||
| 1167 | if ((object)value == null) | 1167 | if (value == null) |
| 1168 | return null; | 1168 | return null; |
| 1169 | 1169 | ||
| 1170 | intPtr = IntPtr.Zero; | 1170 | intPtr = IntPtr.Zero; |
| @@ -1195,7 +1195,7 @@ namespace GSF · 24 unmodified lines | |||
| 1195 | if (string.IsNullOrEmpty(value)) | 1195 | if (string.IsNullOrEmpty(value)) |
| 1196 | return ""; | 1196 | return ""; |
| 1197 | 1197 | ||
| 1198 | if ((object)culture == null) | 1198 | if (culture == null) |
| 1199 | culture = CultureInfo.CurrentCulture; | 1199 | culture = CultureInfo.CurrentCulture; |
| 1200 | 1200 | ||
| 1201 | return culture.TextInfo.ToTitleCase(value.ToLower()); | 1201 | return culture.TextInfo.ToTitleCase(value.ToLower()); |
| @@ -1652,7 +1652,7 @@ namespace GSF · 450 unmodified lines | |||
| 1652 | if (value.Length <= length) | 1652 | if (value.Length <= length) |
| 1653 | return value; | 1653 | return value; |
| 1654 | 1654 | ||
| 1655 | int s1_Len = (int)(length / 2) - 1; | 1655 | int s1_Len = length / 2 - 1; |
| 1656 | 1656 | ||
| 1657 | return string.Concat(value.Substring(0, s1_Len), "...", value.Substring(value.Length - s1_Len + 1 - length % 2)); | 1657 | return string.Concat(value.Substring(0, s1_Len), "...", value.Substring(value.Length - s1_Len + 1 - length % 2)); |
| 1658 | } | 1658 | } |
| @@ -1790,7 +1790,7 @@ namespace GSF · 131 unmodified lines | |||
| 1790 | if (!double.TryParse(value, out test)) | 1790 | if (!double.TryParse(value, out test)) |
| 1791 | return "0"; | 1791 | return "0"; |
| 1792 | 1792 | ||
| 1793 | return test.ToString(); | 1793 | return test.ToString(CultureInfo.InvariantCulture); |
| 1794 | } | 1794 | } |
| 1795 | 1795 | ||
| 1796 | bool isNeg = false; | 1796 | bool isNeg = false; |
| @@ -1998,7 +1998,7 @@ namespace GSF · 201 unmodified lines | |||
| 1998 | /// </summary> | 1998 | /// </summary> |
| 1999 | /// <param name="value">Input string to process.</param> | 1999 | /// <param name="value">Input string to process.</param> |
| 2000 | /// <param name="characterTestFunction">The delegate function used to match characters.</param> | 2000 | /// <param name="characterTestFunction">The delegate function used to match characters.</param> |
| 2001 | /// <param name="startIndex">The index in <paramref name="value"/> from which to begin looking for <paramref name="testChar"/>. Typically length of <paramref name="value"/> minus 1."</param> | 2001 | /// <param name="startIndex">The index in <paramref name="value"/> from which to begin executing test function. Typically length of <paramref name="value"/> minus 1."</param> |
| 2002 | /// <returns>The index of the matching character within <paramref name="value"/> or (-1) if not found.</returns> | 2002 | /// <returns>The index of the matching character within <paramref name="value"/> or (-1) if not found.</returns> |
| 2003 | public static int IndexOfPrevious(this string value, Func<char, bool> characterTestFunction, int startIndex = 0) | 2003 | public static int IndexOfPrevious(this string value, Func<char, bool> characterTestFunction, int startIndex = 0) |
| 2004 | { | 2004 | { |