From fdbb32911835b5ed8e39f518ccc20b0a26bd8bab Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Thu, 9 Jan 2020 17:07:13 +0100 Subject: Remove StringHelper functions --- MediaBrowser.Model/Extensions/StringHelper.cs | 63 ++++++++++----------------- 1 file changed, 22 insertions(+), 41 deletions(-) (limited to 'MediaBrowser.Model/Extensions/StringHelper.cs') diff --git a/MediaBrowser.Model/Extensions/StringHelper.cs b/MediaBrowser.Model/Extensions/StringHelper.cs index 75ba12a17..9ce1cf79f 100644 --- a/MediaBrowser.Model/Extensions/StringHelper.cs +++ b/MediaBrowser.Model/Extensions/StringHelper.cs @@ -1,57 +1,38 @@ -using System; -using System.Text; - namespace MediaBrowser.Model.Extensions { /// - /// Isolating these helpers allow this entire project to be easily converted to Java + /// Helper methods for manipulating strings. /// public static class StringHelper { /// - /// Equalses the ignore case. + /// Returns the string with the first character inheritdoc uppercase. /// - /// The STR1. - /// The STR2. - /// true if XXXX, false otherwise. - public static bool EqualsIgnoreCase(string str1, string str2) + /// The input string. + /// The string with the first character inheritdoc uppercase. + public static string FirstToUpper(string str) { - return string.Equals(str1, str2, StringComparison.OrdinalIgnoreCase); - } - - /// - /// Replaces the specified STR. - /// - /// The STR. - /// The old value. - /// The new value. - /// The comparison. - /// System.String. - public static string Replace(this string str, string oldValue, string newValue, StringComparison comparison) - { - var sb = new StringBuilder(); - - var previousIndex = 0; - var index = str.IndexOf(oldValue, comparison); - - while (index != -1) + if (string.IsNullOrEmpty(str)) { - sb.Append(str.Substring(previousIndex, index - previousIndex)); - sb.Append(newValue); - index += oldValue.Length; - - previousIndex = index; - index = str.IndexOf(oldValue, index, comparison); + return string.Empty; } - sb.Append(str.Substring(previousIndex)); - - return sb.ToString(); - } + if (char.IsUpper(str[0])) + { + return str; + } - public static string FirstToUpper(this string str) - { - return string.IsNullOrEmpty(str) ? string.Empty : str.Substring(0, 1).ToUpperInvariant() + str.Substring(1); + return string.Create( + str.Length, + str, + (chars, buf) => + { + chars[0] = char.ToUpperInvariant(buf[0]); + for (int i = 1; i Date: Thu, 16 Jan 2020 23:22:42 +0100 Subject: Update StringHelper.cs --- MediaBrowser.Model/Extensions/StringHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MediaBrowser.Model/Extensions/StringHelper.cs') diff --git a/MediaBrowser.Model/Extensions/StringHelper.cs b/MediaBrowser.Model/Extensions/StringHelper.cs index 9ce1cf79f..a4ba4b069 100644 --- a/MediaBrowser.Model/Extensions/StringHelper.cs +++ b/MediaBrowser.Model/Extensions/StringHelper.cs @@ -6,7 +6,7 @@ namespace MediaBrowser.Model.Extensions public static class StringHelper { /// - /// Returns the string with the first character inheritdoc uppercase. + /// Returns the string with the first character as uppercase. /// /// The input string. /// The string with the first character inheritdoc uppercase. -- cgit v1.2.3 From 686d1ff9fb68fbb4b05022bdd141d17f2f720515 Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Thu, 16 Jan 2020 23:23:06 +0100 Subject: Update StringHelper.cs --- MediaBrowser.Model/Extensions/StringHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MediaBrowser.Model/Extensions/StringHelper.cs') diff --git a/MediaBrowser.Model/Extensions/StringHelper.cs b/MediaBrowser.Model/Extensions/StringHelper.cs index a4ba4b069..586412054 100644 --- a/MediaBrowser.Model/Extensions/StringHelper.cs +++ b/MediaBrowser.Model/Extensions/StringHelper.cs @@ -9,7 +9,7 @@ namespace MediaBrowser.Model.Extensions /// Returns the string with the first character as uppercase. /// /// The input string. - /// The string with the first character inheritdoc uppercase. + /// The string with the first character as uppercase. public static string FirstToUpper(string str) { if (string.IsNullOrEmpty(str)) -- cgit v1.2.3 From 6cd9c84ddf4940a5db1c3d84f1f61a89e5b4e168 Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Fri, 31 Jan 2020 18:10:15 +0100 Subject: Update MediaBrowser.Model/Extensions/StringHelper.cs Co-Authored-By: dkanada --- MediaBrowser.Model/Extensions/StringHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MediaBrowser.Model/Extensions/StringHelper.cs') diff --git a/MediaBrowser.Model/Extensions/StringHelper.cs b/MediaBrowser.Model/Extensions/StringHelper.cs index 586412054..f97a07096 100644 --- a/MediaBrowser.Model/Extensions/StringHelper.cs +++ b/MediaBrowser.Model/Extensions/StringHelper.cs @@ -28,7 +28,7 @@ namespace MediaBrowser.Model.Extensions (chars, buf) => { chars[0] = char.ToUpperInvariant(buf[0]); - for (int i = 1; i