Merge pull request #2247 from Bond-009/stringhelper

Remove StringHelper functions
This commit is contained in:
dkanada 2020-02-01 03:29:16 +09:00 committed by GitHub
commit cd13f718fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 146 additions and 164 deletions

View File

@ -9,7 +9,7 @@
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.1</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup> </PropertyGroup>

View File

@ -16,7 +16,7 @@ namespace Emby.Dlna.Didl
public Filter(string filter) public Filter(string filter)
{ {
_all = StringHelper.EqualsIgnoreCase(filter, "*"); _all = string.Equals(filter, "*", StringComparison.OrdinalIgnoreCase);
_fields = (filter ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); _fields = (filter ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
} }

View File

@ -427,7 +427,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{ {
foreach (NameValuePair mapping in mappings) foreach (NameValuePair mapping in mappings)
{ {
if (StringHelper.EqualsIgnoreCase(mapping.Name, channelId)) if (string.Equals(mapping.Name, channelId, StringComparison.OrdinalIgnoreCase))
{ {
return mapping.Value; return mapping.Value;
} }

View File

@ -169,9 +169,9 @@ namespace MediaBrowser.Model.Dlna
return ListHelper.ContainsIgnoreCase(expected.Split('|'), currentValue); return ListHelper.ContainsIgnoreCase(expected.Split('|'), currentValue);
} }
case ProfileConditionType.Equals: case ProfileConditionType.Equals:
return StringHelper.EqualsIgnoreCase(currentValue, expected); return string.Equals(currentValue, expected, StringComparison.OrdinalIgnoreCase);
case ProfileConditionType.NotEquals: case ProfileConditionType.NotEquals:
return !StringHelper.EqualsIgnoreCase(currentValue, expected); return !string.Equals(currentValue, expected, StringComparison.OrdinalIgnoreCase);
default: default:
throw new InvalidOperationException("Unexpected ProfileConditionType: " + condition.Condition); throw new InvalidOperationException("Unexpected ProfileConditionType: " + condition.Condition);
} }

View File

@ -122,7 +122,7 @@ namespace MediaBrowser.Model.Dlna
continue; continue;
} }
if (!StringHelper.EqualsIgnoreCase(container, i.Container)) if (!string.Equals(container, i.Container, StringComparison.OrdinalIgnoreCase))
{ {
continue; continue;
} }
@ -148,7 +148,7 @@ namespace MediaBrowser.Model.Dlna
continue; continue;
} }
if (!StringHelper.EqualsIgnoreCase(container, i.Container)) if (!string.Equals(container, i.Container, StringComparison.OrdinalIgnoreCase))
{ {
continue; continue;
} }
@ -158,7 +158,7 @@ namespace MediaBrowser.Model.Dlna
continue; continue;
} }
if (!StringHelper.EqualsIgnoreCase(videoCodec, i.VideoCodec ?? string.Empty)) if (!string.Equals(videoCodec, i.VideoCodec ?? string.Empty, StringComparison.OrdinalIgnoreCase))
{ {
continue; continue;
} }

View File

@ -17,53 +17,53 @@ namespace MediaBrowser.Model.Dlna
private MediaFormatProfile[] ResolveVideoFormatInternal(string container, string videoCodec, string audioCodec, int? width, int? height, TransportStreamTimestamp timestampType) private MediaFormatProfile[] ResolveVideoFormatInternal(string container, string videoCodec, string audioCodec, int? width, int? height, TransportStreamTimestamp timestampType)
{ {
if (StringHelper.EqualsIgnoreCase(container, "asf")) if (string.Equals(container, "asf", StringComparison.OrdinalIgnoreCase))
{ {
MediaFormatProfile? val = ResolveVideoASFFormat(videoCodec, audioCodec, width, height); MediaFormatProfile? val = ResolveVideoASFFormat(videoCodec, audioCodec, width, height);
return val.HasValue ? new MediaFormatProfile[] { val.Value } : new MediaFormatProfile[] { }; return val.HasValue ? new MediaFormatProfile[] { val.Value } : new MediaFormatProfile[] { };
} }
if (StringHelper.EqualsIgnoreCase(container, "mp4")) if (string.Equals(container, "mp4", StringComparison.OrdinalIgnoreCase))
{ {
MediaFormatProfile? val = ResolveVideoMP4Format(videoCodec, audioCodec, width, height); MediaFormatProfile? val = ResolveVideoMP4Format(videoCodec, audioCodec, width, height);
return val.HasValue ? new MediaFormatProfile[] { val.Value } : new MediaFormatProfile[] { }; return val.HasValue ? new MediaFormatProfile[] { val.Value } : new MediaFormatProfile[] { };
} }
if (StringHelper.EqualsIgnoreCase(container, "avi")) if (string.Equals(container, "avi", StringComparison.OrdinalIgnoreCase))
return new MediaFormatProfile[] { MediaFormatProfile.AVI }; return new MediaFormatProfile[] { MediaFormatProfile.AVI };
if (StringHelper.EqualsIgnoreCase(container, "mkv")) if (string.Equals(container, "mkv", StringComparison.OrdinalIgnoreCase))
return new MediaFormatProfile[] { MediaFormatProfile.MATROSKA }; return new MediaFormatProfile[] { MediaFormatProfile.MATROSKA };
if (StringHelper.EqualsIgnoreCase(container, "mpeg2ps") || if (string.Equals(container, "mpeg2ps", StringComparison.OrdinalIgnoreCase) ||
StringHelper.EqualsIgnoreCase(container, "ts")) string.Equals(container, "ts", StringComparison.OrdinalIgnoreCase))
return new MediaFormatProfile[] { MediaFormatProfile.MPEG_PS_NTSC, MediaFormatProfile.MPEG_PS_PAL }; return new MediaFormatProfile[] { MediaFormatProfile.MPEG_PS_NTSC, MediaFormatProfile.MPEG_PS_PAL };
if (StringHelper.EqualsIgnoreCase(container, "mpeg1video")) if (string.Equals(container, "mpeg1video", StringComparison.OrdinalIgnoreCase))
return new MediaFormatProfile[] { MediaFormatProfile.MPEG1 }; return new MediaFormatProfile[] { MediaFormatProfile.MPEG1 };
if (StringHelper.EqualsIgnoreCase(container, "mpeg2ts") || if (string.Equals(container, "mpeg2ts", StringComparison.OrdinalIgnoreCase) ||
StringHelper.EqualsIgnoreCase(container, "mpegts") || string.Equals(container, "mpegts", StringComparison.OrdinalIgnoreCase) ||
StringHelper.EqualsIgnoreCase(container, "m2ts")) string.Equals(container, "m2ts", StringComparison.OrdinalIgnoreCase))
{ {
return ResolveVideoMPEG2TSFormat(videoCodec, audioCodec, width, height, timestampType); return ResolveVideoMPEG2TSFormat(videoCodec, audioCodec, width, height, timestampType);
} }
if (StringHelper.EqualsIgnoreCase(container, "flv")) if (string.Equals(container, "flv", StringComparison.OrdinalIgnoreCase))
return new MediaFormatProfile[] { MediaFormatProfile.FLV }; return new MediaFormatProfile[] { MediaFormatProfile.FLV };
if (StringHelper.EqualsIgnoreCase(container, "wtv")) if (string.Equals(container, "wtv", StringComparison.OrdinalIgnoreCase))
return new MediaFormatProfile[] { MediaFormatProfile.WTV }; return new MediaFormatProfile[] { MediaFormatProfile.WTV };
if (StringHelper.EqualsIgnoreCase(container, "3gp")) if (string.Equals(container, "3gp", StringComparison.OrdinalIgnoreCase))
{ {
MediaFormatProfile? val = ResolveVideo3GPFormat(videoCodec, audioCodec); MediaFormatProfile? val = ResolveVideo3GPFormat(videoCodec, audioCodec);
return val.HasValue ? new MediaFormatProfile[] { val.Value } : new MediaFormatProfile[] { }; return val.HasValue ? new MediaFormatProfile[] { val.Value } : new MediaFormatProfile[] { };
} }
if (StringHelper.EqualsIgnoreCase(container, "ogv") || StringHelper.EqualsIgnoreCase(container, "ogg")) if (string.Equals(container, "ogv", StringComparison.OrdinalIgnoreCase) || string.Equals(container, "ogg", StringComparison.OrdinalIgnoreCase))
return new MediaFormatProfile[] { MediaFormatProfile.OGV }; return new MediaFormatProfile[] { MediaFormatProfile.OGV };
return new MediaFormatProfile[] { }; return new MediaFormatProfile[] { };
@ -89,7 +89,7 @@ namespace MediaBrowser.Model.Dlna
resolution = "H"; resolution = "H";
} }
if (StringHelper.EqualsIgnoreCase(videoCodec, "mpeg2video")) if (string.Equals(videoCodec, "mpeg2video", StringComparison.OrdinalIgnoreCase))
{ {
var list = new List<MediaFormatProfile>(); var list = new List<MediaFormatProfile>();
@ -97,18 +97,18 @@ namespace MediaBrowser.Model.Dlna
list.Add(ValueOf("MPEG_TS_SD_EU" + suffix)); list.Add(ValueOf("MPEG_TS_SD_EU" + suffix));
list.Add(ValueOf("MPEG_TS_SD_KO" + suffix)); list.Add(ValueOf("MPEG_TS_SD_KO" + suffix));
if ((timestampType == TransportStreamTimestamp.Valid) && StringHelper.EqualsIgnoreCase(audioCodec, "aac")) if ((timestampType == TransportStreamTimestamp.Valid) && string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
{ {
list.Add(MediaFormatProfile.MPEG_TS_JP_T); list.Add(MediaFormatProfile.MPEG_TS_JP_T);
} }
return list.ToArray(); return list.ToArray();
} }
if (StringHelper.EqualsIgnoreCase(videoCodec, "h264")) if (string.Equals(videoCodec, "h264", StringComparison.OrdinalIgnoreCase))
{ {
if (StringHelper.EqualsIgnoreCase(audioCodec, "lpcm")) if (string.Equals(audioCodec, "lpcm", StringComparison.OrdinalIgnoreCase))
return new MediaFormatProfile[] { MediaFormatProfile.AVC_TS_HD_50_LPCM_T }; return new MediaFormatProfile[] { MediaFormatProfile.AVC_TS_HD_50_LPCM_T };
if (StringHelper.EqualsIgnoreCase(audioCodec, "dts")) if (string.Equals(audioCodec, "dts", StringComparison.OrdinalIgnoreCase))
{ {
if (timestampType == TransportStreamTimestamp.None) if (timestampType == TransportStreamTimestamp.None)
{ {
@ -117,7 +117,7 @@ namespace MediaBrowser.Model.Dlna
return new MediaFormatProfile[] { MediaFormatProfile.AVC_TS_HD_DTS_T }; return new MediaFormatProfile[] { MediaFormatProfile.AVC_TS_HD_DTS_T };
} }
if (StringHelper.EqualsIgnoreCase(audioCodec, "mp2")) if (string.Equals(audioCodec, "mp2", StringComparison.OrdinalIgnoreCase))
{ {
if (timestampType == TransportStreamTimestamp.None) if (timestampType == TransportStreamTimestamp.None)
{ {
@ -127,19 +127,19 @@ namespace MediaBrowser.Model.Dlna
return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_HP_{0}D_MPEG1_L2_T", resolution)) }; return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_HP_{0}D_MPEG1_L2_T", resolution)) };
} }
if (StringHelper.EqualsIgnoreCase(audioCodec, "aac")) if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_MP_{0}D_AAC_MULT5{1}", resolution, suffix)) }; return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_MP_{0}D_AAC_MULT5{1}", resolution, suffix)) };
if (StringHelper.EqualsIgnoreCase(audioCodec, "mp3")) if (string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase))
return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_MP_{0}D_MPEG1_L3{1}", resolution, suffix)) }; return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_MP_{0}D_MPEG1_L3{1}", resolution, suffix)) };
if (string.IsNullOrEmpty(audioCodec) || if (string.IsNullOrEmpty(audioCodec) ||
StringHelper.EqualsIgnoreCase(audioCodec, "ac3")) string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase))
return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_MP_{0}D_AC3{1}", resolution, suffix)) }; return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_MP_{0}D_AC3{1}", resolution, suffix)) };
} }
else if (StringHelper.EqualsIgnoreCase(videoCodec, "vc1")) else if (string.Equals(videoCodec, "vc1", StringComparison.OrdinalIgnoreCase))
{ {
if (string.IsNullOrEmpty(audioCodec) || StringHelper.EqualsIgnoreCase(audioCodec, "ac3")) if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase))
{ {
if ((width.HasValue && width.Value > 720) || (height.HasValue && height.Value > 576)) if ((width.HasValue && width.Value > 720) || (height.HasValue && height.Value > 576))
{ {
@ -147,23 +147,23 @@ namespace MediaBrowser.Model.Dlna
} }
return new MediaFormatProfile[] { MediaFormatProfile.VC1_TS_AP_L1_AC3_ISO }; return new MediaFormatProfile[] { MediaFormatProfile.VC1_TS_AP_L1_AC3_ISO };
} }
if (StringHelper.EqualsIgnoreCase(audioCodec, "dts")) if (string.Equals(audioCodec, "dts", StringComparison.OrdinalIgnoreCase))
{ {
suffix = StringHelper.EqualsIgnoreCase(suffix, "_ISO") ? suffix : "_T"; suffix = string.Equals(suffix, "_ISO", StringComparison.OrdinalIgnoreCase) ? suffix : "_T";
return new MediaFormatProfile[] { ValueOf(string.Format("VC1_TS_HD_DTS{0}", suffix)) }; return new MediaFormatProfile[] { ValueOf(string.Format("VC1_TS_HD_DTS{0}", suffix)) };
} }
} }
else if (StringHelper.EqualsIgnoreCase(videoCodec, "mpeg4") || StringHelper.EqualsIgnoreCase(videoCodec, "msmpeg4")) else if (string.Equals(videoCodec, "mpeg4", StringComparison.OrdinalIgnoreCase) || string.Equals(videoCodec, "msmpeg4", StringComparison.OrdinalIgnoreCase))
{ {
if (StringHelper.EqualsIgnoreCase(audioCodec, "aac")) if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_AAC{0}", suffix)) }; return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_AAC{0}", suffix)) };
if (StringHelper.EqualsIgnoreCase(audioCodec, "mp3")) if (string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase))
return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_MPEG1_L3{0}", suffix)) }; return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_MPEG1_L3{0}", suffix)) };
if (StringHelper.EqualsIgnoreCase(audioCodec, "mp2")) if (string.Equals(audioCodec, "mp2", StringComparison.OrdinalIgnoreCase))
return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_MPEG2_L2{0}", suffix)) }; return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_MPEG2_L2{0}", suffix)) };
if (StringHelper.EqualsIgnoreCase(audioCodec, "ac3")) if (string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase))
return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_AC3{0}", suffix)) }; return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_AC3{0}", suffix)) };
} }
@ -177,16 +177,16 @@ namespace MediaBrowser.Model.Dlna
private MediaFormatProfile? ResolveVideoMP4Format(string videoCodec, string audioCodec, int? width, int? height) private MediaFormatProfile? ResolveVideoMP4Format(string videoCodec, string audioCodec, int? width, int? height)
{ {
if (StringHelper.EqualsIgnoreCase(videoCodec, "h264")) if (string.Equals(videoCodec, "h264", StringComparison.OrdinalIgnoreCase))
{ {
if (StringHelper.EqualsIgnoreCase(audioCodec, "lpcm")) if (string.Equals(audioCodec, "lpcm", StringComparison.OrdinalIgnoreCase))
return MediaFormatProfile.AVC_MP4_LPCM; return MediaFormatProfile.AVC_MP4_LPCM;
if (string.IsNullOrEmpty(audioCodec) || if (string.IsNullOrEmpty(audioCodec) ||
StringHelper.EqualsIgnoreCase(audioCodec, "ac3")) string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase))
{ {
return MediaFormatProfile.AVC_MP4_MP_SD_AC3; return MediaFormatProfile.AVC_MP4_MP_SD_AC3;
} }
if (StringHelper.EqualsIgnoreCase(audioCodec, "mp3")) if (string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase))
{ {
return MediaFormatProfile.AVC_MP4_MP_SD_MPEG1_L3; return MediaFormatProfile.AVC_MP4_MP_SD_MPEG1_L3;
} }
@ -194,41 +194,41 @@ namespace MediaBrowser.Model.Dlna
{ {
if ((width.Value <= 720) && (height.Value <= 576)) if ((width.Value <= 720) && (height.Value <= 576))
{ {
if (StringHelper.EqualsIgnoreCase(audioCodec, "aac")) if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
return MediaFormatProfile.AVC_MP4_MP_SD_AAC_MULT5; return MediaFormatProfile.AVC_MP4_MP_SD_AAC_MULT5;
} }
else if ((width.Value <= 1280) && (height.Value <= 720)) else if ((width.Value <= 1280) && (height.Value <= 720))
{ {
if (StringHelper.EqualsIgnoreCase(audioCodec, "aac")) if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
return MediaFormatProfile.AVC_MP4_MP_HD_720p_AAC; return MediaFormatProfile.AVC_MP4_MP_HD_720p_AAC;
} }
else if ((width.Value <= 1920) && (height.Value <= 1080)) else if ((width.Value <= 1920) && (height.Value <= 1080))
{ {
if (StringHelper.EqualsIgnoreCase(audioCodec, "aac")) if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
{ {
return MediaFormatProfile.AVC_MP4_MP_HD_1080i_AAC; return MediaFormatProfile.AVC_MP4_MP_HD_1080i_AAC;
} }
} }
} }
} }
else if (StringHelper.EqualsIgnoreCase(videoCodec, "mpeg4") || else if (string.Equals(videoCodec, "mpeg4", StringComparison.OrdinalIgnoreCase) ||
StringHelper.EqualsIgnoreCase(videoCodec, "msmpeg4")) string.Equals(videoCodec, "msmpeg4", StringComparison.OrdinalIgnoreCase))
{ {
if (width.HasValue && height.HasValue && width.Value <= 720 && height.Value <= 576) if (width.HasValue && height.HasValue && width.Value <= 720 && height.Value <= 576)
{ {
if (string.IsNullOrEmpty(audioCodec) || StringHelper.EqualsIgnoreCase(audioCodec, "aac")) if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
return MediaFormatProfile.MPEG4_P2_MP4_ASP_AAC; return MediaFormatProfile.MPEG4_P2_MP4_ASP_AAC;
if (StringHelper.EqualsIgnoreCase(audioCodec, "ac3") || StringHelper.EqualsIgnoreCase(audioCodec, "mp3")) if (string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase) || string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase))
{ {
return MediaFormatProfile.MPEG4_P2_MP4_NDSD; return MediaFormatProfile.MPEG4_P2_MP4_NDSD;
} }
} }
else if (string.IsNullOrEmpty(audioCodec) || StringHelper.EqualsIgnoreCase(audioCodec, "aac")) else if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
{ {
return MediaFormatProfile.MPEG4_P2_MP4_SP_L6_AAC; return MediaFormatProfile.MPEG4_P2_MP4_SP_L6_AAC;
} }
} }
else if (StringHelper.EqualsIgnoreCase(videoCodec, "h263") && StringHelper.EqualsIgnoreCase(audioCodec, "aac")) else if (string.Equals(videoCodec, "h263", StringComparison.OrdinalIgnoreCase) && string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
{ {
return MediaFormatProfile.MPEG4_H263_MP4_P0_L10_AAC; return MediaFormatProfile.MPEG4_H263_MP4_P0_L10_AAC;
} }
@ -238,20 +238,20 @@ namespace MediaBrowser.Model.Dlna
private MediaFormatProfile? ResolveVideo3GPFormat(string videoCodec, string audioCodec) private MediaFormatProfile? ResolveVideo3GPFormat(string videoCodec, string audioCodec)
{ {
if (StringHelper.EqualsIgnoreCase(videoCodec, "h264")) if (string.Equals(videoCodec, "h264", StringComparison.OrdinalIgnoreCase))
{ {
if (string.IsNullOrEmpty(audioCodec) || StringHelper.EqualsIgnoreCase(audioCodec, "aac")) if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
return MediaFormatProfile.AVC_3GPP_BL_QCIF15_AAC; return MediaFormatProfile.AVC_3GPP_BL_QCIF15_AAC;
} }
else if (StringHelper.EqualsIgnoreCase(videoCodec, "mpeg4") || else if (string.Equals(videoCodec, "mpeg4", StringComparison.OrdinalIgnoreCase) ||
StringHelper.EqualsIgnoreCase(videoCodec, "msmpeg4")) string.Equals(videoCodec, "msmpeg4", StringComparison.OrdinalIgnoreCase))
{ {
if (string.IsNullOrEmpty(audioCodec) || StringHelper.EqualsIgnoreCase(audioCodec, "wma")) if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "wma", StringComparison.OrdinalIgnoreCase))
return MediaFormatProfile.MPEG4_P2_3GPP_SP_L0B_AAC; return MediaFormatProfile.MPEG4_P2_3GPP_SP_L0B_AAC;
if (StringHelper.EqualsIgnoreCase(audioCodec, "amrnb")) if (string.Equals(audioCodec, "amrnb", StringComparison.OrdinalIgnoreCase))
return MediaFormatProfile.MPEG4_P2_3GPP_SP_L0B_AMR; return MediaFormatProfile.MPEG4_P2_3GPP_SP_L0B_AMR;
} }
else if (StringHelper.EqualsIgnoreCase(videoCodec, "h263") && StringHelper.EqualsIgnoreCase(audioCodec, "amrnb")) else if (string.Equals(videoCodec, "h263", StringComparison.OrdinalIgnoreCase) && string.Equals(audioCodec, "amrnb", StringComparison.OrdinalIgnoreCase))
{ {
return MediaFormatProfile.MPEG4_H263_3GPP_P0_L10_AMR; return MediaFormatProfile.MPEG4_H263_3GPP_P0_L10_AMR;
} }
@ -261,15 +261,15 @@ namespace MediaBrowser.Model.Dlna
private MediaFormatProfile? ResolveVideoASFFormat(string videoCodec, string audioCodec, int? width, int? height) private MediaFormatProfile? ResolveVideoASFFormat(string videoCodec, string audioCodec, int? width, int? height)
{ {
if (StringHelper.EqualsIgnoreCase(videoCodec, "wmv") && if (string.Equals(videoCodec, "wmv", StringComparison.OrdinalIgnoreCase) &&
(string.IsNullOrEmpty(audioCodec) || StringHelper.EqualsIgnoreCase(audioCodec, "wma") || StringHelper.EqualsIgnoreCase(videoCodec, "wmapro"))) (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "wma", StringComparison.OrdinalIgnoreCase) || string.Equals(videoCodec, "wmapro", StringComparison.OrdinalIgnoreCase)))
{ {
if (width.HasValue && height.HasValue) if (width.HasValue && height.HasValue)
{ {
if ((width.Value <= 720) && (height.Value <= 576)) if ((width.Value <= 720) && (height.Value <= 576))
{ {
if (string.IsNullOrEmpty(audioCodec) || StringHelper.EqualsIgnoreCase(audioCodec, "wma")) if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "wma", StringComparison.OrdinalIgnoreCase))
{ {
return MediaFormatProfile.WMVMED_FULL; return MediaFormatProfile.WMVMED_FULL;
} }
@ -277,14 +277,14 @@ namespace MediaBrowser.Model.Dlna
} }
} }
if (string.IsNullOrEmpty(audioCodec) || StringHelper.EqualsIgnoreCase(audioCodec, "wma")) if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "wma", StringComparison.OrdinalIgnoreCase))
{ {
return MediaFormatProfile.WMVHIGH_FULL; return MediaFormatProfile.WMVHIGH_FULL;
} }
return MediaFormatProfile.WMVHIGH_PRO; return MediaFormatProfile.WMVHIGH_PRO;
} }
if (StringHelper.EqualsIgnoreCase(videoCodec, "vc1")) if (string.Equals(videoCodec, "vc1", StringComparison.OrdinalIgnoreCase))
{ {
if (width.HasValue && height.HasValue) if (width.HasValue && height.HasValue)
{ {
@ -296,7 +296,7 @@ namespace MediaBrowser.Model.Dlna
return MediaFormatProfile.VC1_ASF_AP_L3_WMA; return MediaFormatProfile.VC1_ASF_AP_L3_WMA;
} }
} }
else if (StringHelper.EqualsIgnoreCase(videoCodec, "mpeg2video")) else if (string.Equals(videoCodec, "mpeg2video", StringComparison.OrdinalIgnoreCase))
{ {
return MediaFormatProfile.DVR_MS; return MediaFormatProfile.DVR_MS;
} }
@ -306,27 +306,27 @@ namespace MediaBrowser.Model.Dlna
public MediaFormatProfile? ResolveAudioFormat(string container, int? bitrate, int? frequency, int? channels) public MediaFormatProfile? ResolveAudioFormat(string container, int? bitrate, int? frequency, int? channels)
{ {
if (StringHelper.EqualsIgnoreCase(container, "asf")) if (string.Equals(container, "asf", StringComparison.OrdinalIgnoreCase))
return ResolveAudioASFFormat(bitrate); return ResolveAudioASFFormat(bitrate);
if (StringHelper.EqualsIgnoreCase(container, "mp3")) if (string.Equals(container, "mp3", StringComparison.OrdinalIgnoreCase))
return MediaFormatProfile.MP3; return MediaFormatProfile.MP3;
if (StringHelper.EqualsIgnoreCase(container, "lpcm")) if (string.Equals(container, "lpcm", StringComparison.OrdinalIgnoreCase))
return ResolveAudioLPCMFormat(frequency, channels); return ResolveAudioLPCMFormat(frequency, channels);
if (StringHelper.EqualsIgnoreCase(container, "mp4") || if (string.Equals(container, "mp4", StringComparison.OrdinalIgnoreCase) ||
StringHelper.EqualsIgnoreCase(container, "aac")) string.Equals(container, "aac", StringComparison.OrdinalIgnoreCase))
return ResolveAudioMP4Format(bitrate); return ResolveAudioMP4Format(bitrate);
if (StringHelper.EqualsIgnoreCase(container, "adts")) if (string.Equals(container, "adts", StringComparison.OrdinalIgnoreCase))
return ResolveAudioADTSFormat(bitrate); return ResolveAudioADTSFormat(bitrate);
if (StringHelper.EqualsIgnoreCase(container, "flac")) if (string.Equals(container, "flac", StringComparison.OrdinalIgnoreCase))
return MediaFormatProfile.FLAC; return MediaFormatProfile.FLAC;
if (StringHelper.EqualsIgnoreCase(container, "oga") || if (string.Equals(container, "oga", StringComparison.OrdinalIgnoreCase) ||
StringHelper.EqualsIgnoreCase(container, "ogg")) string.Equals(container, "ogg", StringComparison.OrdinalIgnoreCase))
return MediaFormatProfile.OGG; return MediaFormatProfile.OGG;
return null; return null;
@ -388,17 +388,17 @@ namespace MediaBrowser.Model.Dlna
public MediaFormatProfile? ResolveImageFormat(string container, int? width, int? height) public MediaFormatProfile? ResolveImageFormat(string container, int? width, int? height)
{ {
if (StringHelper.EqualsIgnoreCase(container, "jpeg") || if (string.Equals(container, "jpeg", StringComparison.OrdinalIgnoreCase) ||
StringHelper.EqualsIgnoreCase(container, "jpg")) string.Equals(container, "jpg", StringComparison.OrdinalIgnoreCase))
return ResolveImageJPGFormat(width, height); return ResolveImageJPGFormat(width, height);
if (StringHelper.EqualsIgnoreCase(container, "png")) if (string.Equals(container, "png", StringComparison.OrdinalIgnoreCase))
return ResolveImagePNGFormat(width, height); return ResolveImagePNGFormat(width, height);
if (StringHelper.EqualsIgnoreCase(container, "gif")) if (string.Equals(container, "gif", StringComparison.OrdinalIgnoreCase))
return MediaFormatProfile.GIF_LRG; return MediaFormatProfile.GIF_LRG;
if (StringHelper.EqualsIgnoreCase(container, "raw")) if (string.Equals(container, "raw", StringComparison.OrdinalIgnoreCase))
return MediaFormatProfile.RAW; return MediaFormatProfile.RAW;
return null; return null;

View File

@ -76,9 +76,9 @@ namespace MediaBrowser.Model.Dlna
private static double GetVideoBitrateScaleFactor(string codec) private static double GetVideoBitrateScaleFactor(string codec)
{ {
if (StringHelper.EqualsIgnoreCase(codec, "h265") || if (string.Equals(codec, "h265", StringComparison.OrdinalIgnoreCase) ||
StringHelper.EqualsIgnoreCase(codec, "hevc") || string.Equals(codec, "hevc", StringComparison.OrdinalIgnoreCase) ||
StringHelper.EqualsIgnoreCase(codec, "vp9")) string.Equals(codec, "vp9", StringComparison.OrdinalIgnoreCase))
{ {
return .5; return .5;
} }

View File

@ -48,22 +48,22 @@ namespace MediaBrowser.Model.Dlna
if (subFactors.Length == 3) if (subFactors.Length == 3)
{ {
if (StringHelper.EqualsIgnoreCase("upnp:class", subFactors[0]) && if (string.Equals("upnp:class", subFactors[0], StringComparison.OrdinalIgnoreCase) &&
(StringHelper.EqualsIgnoreCase("=", subFactors[1]) || StringHelper.EqualsIgnoreCase("derivedfrom", subFactors[1]))) (string.Equals("=", subFactors[1]) || string.Equals("derivedfrom", subFactors[1], StringComparison.OrdinalIgnoreCase)))
{ {
if (StringHelper.EqualsIgnoreCase("\"object.item.imageItem\"", subFactors[2]) || StringHelper.EqualsIgnoreCase("\"object.item.imageItem.photo\"", subFactors[2])) if (string.Equals("\"object.item.imageItem\"", subFactors[2]) || string.Equals("\"object.item.imageItem.photo\"", subFactors[2], StringComparison.OrdinalIgnoreCase))
{ {
SearchType = SearchType.Image; SearchType = SearchType.Image;
} }
else if (StringHelper.EqualsIgnoreCase("\"object.item.videoItem\"", subFactors[2])) else if (string.Equals("\"object.item.videoItem\"", subFactors[2], StringComparison.OrdinalIgnoreCase))
{ {
SearchType = SearchType.Video; SearchType = SearchType.Video;
} }
else if (StringHelper.EqualsIgnoreCase("\"object.container.playlistContainer\"", subFactors[2])) else if (string.Equals("\"object.container.playlistContainer\"", subFactors[2], StringComparison.OrdinalIgnoreCase))
{ {
SearchType = SearchType.Playlist; SearchType = SearchType.Playlist;
} }
else if (StringHelper.EqualsIgnoreCase("\"object.container.album.musicAlbum\"", subFactors[2])) else if (string.Equals("\"object.container.album.musicAlbum\"", subFactors[2], StringComparison.OrdinalIgnoreCase))
{ {
SearchType = SearchType.MusicAlbum; SearchType = SearchType.MusicAlbum;
} }

View File

@ -35,7 +35,7 @@ namespace MediaBrowser.Model.Dlna
foreach (MediaSourceInfo i in options.MediaSources) foreach (MediaSourceInfo i in options.MediaSources)
{ {
if (string.IsNullOrEmpty(options.MediaSourceId) || if (string.IsNullOrEmpty(options.MediaSourceId) ||
StringHelper.EqualsIgnoreCase(i.Id, options.MediaSourceId)) string.Equals(i.Id, options.MediaSourceId, StringComparison.OrdinalIgnoreCase))
{ {
mediaSources.Add(i); mediaSources.Add(i);
} }
@ -68,7 +68,7 @@ namespace MediaBrowser.Model.Dlna
foreach (MediaSourceInfo i in options.MediaSources) foreach (MediaSourceInfo i in options.MediaSources)
{ {
if (string.IsNullOrEmpty(options.MediaSourceId) || if (string.IsNullOrEmpty(options.MediaSourceId) ||
StringHelper.EqualsIgnoreCase(i.Id, options.MediaSourceId)) string.Equals(i.Id, options.MediaSourceId, StringComparison.OrdinalIgnoreCase))
{ {
mediaSources.Add(i); mediaSources.Add(i);
} }
@ -582,7 +582,7 @@ namespace MediaBrowser.Model.Dlna
{ {
foreach (var profile in subtitleProfiles) foreach (var profile in subtitleProfiles)
{ {
if (profile.Method == SubtitleDeliveryMethod.External && StringHelper.EqualsIgnoreCase(profile.Format, stream.Codec)) if (profile.Method == SubtitleDeliveryMethod.External && string.Equals(profile.Format, stream.Codec, StringComparison.OrdinalIgnoreCase))
{ {
return stream.Index; return stream.Index;
} }
@ -1198,7 +1198,7 @@ namespace MediaBrowser.Model.Dlna
continue; continue;
} }
if (subtitleStream.IsTextSubtitleStream == MediaStream.IsTextFormat(profile.Format) && StringHelper.EqualsIgnoreCase(profile.Format, subtitleStream.Codec)) if (subtitleStream.IsTextSubtitleStream == MediaStream.IsTextFormat(profile.Format) && string.Equals(profile.Format, subtitleStream.Codec, StringComparison.OrdinalIgnoreCase))
{ {
return profile; return profile;
} }
@ -1292,7 +1292,7 @@ namespace MediaBrowser.Model.Dlna
if ((profile.Method == SubtitleDeliveryMethod.External && subtitleStream.IsTextSubtitleStream == MediaStream.IsTextFormat(profile.Format)) || if ((profile.Method == SubtitleDeliveryMethod.External && subtitleStream.IsTextSubtitleStream == MediaStream.IsTextFormat(profile.Format)) ||
(profile.Method == SubtitleDeliveryMethod.Hls && subtitleStream.IsTextSubtitleStream)) (profile.Method == SubtitleDeliveryMethod.Hls && subtitleStream.IsTextSubtitleStream))
{ {
bool requiresConversion = !StringHelper.EqualsIgnoreCase(subtitleStream.Codec, profile.Format); bool requiresConversion = !string.Equals(subtitleStream.Codec, profile.Format, StringComparison.OrdinalIgnoreCase);
if (!requiresConversion) if (!requiresConversion)
{ {

View File

@ -153,18 +153,18 @@ namespace MediaBrowser.Model.Dlna
} }
// Try to keep the url clean by omitting defaults // Try to keep the url clean by omitting defaults
if (StringHelper.EqualsIgnoreCase(pair.Name, "StartTimeTicks") && if (string.Equals(pair.Name, "StartTimeTicks", StringComparison.OrdinalIgnoreCase) &&
StringHelper.EqualsIgnoreCase(pair.Value, "0")) string.Equals(pair.Value, "0", StringComparison.OrdinalIgnoreCase))
{ {
continue; continue;
} }
if (StringHelper.EqualsIgnoreCase(pair.Name, "SubtitleStreamIndex") && if (string.Equals(pair.Name, "SubtitleStreamIndex", StringComparison.OrdinalIgnoreCase) &&
StringHelper.EqualsIgnoreCase(pair.Value, "-1")) string.Equals(pair.Value, "-1", StringComparison.OrdinalIgnoreCase))
{ {
continue; continue;
} }
if (StringHelper.EqualsIgnoreCase(pair.Name, "Static") && if (string.Equals(pair.Name, "Static", StringComparison.OrdinalIgnoreCase) &&
StringHelper.EqualsIgnoreCase(pair.Value, "false")) string.Equals(pair.Value, "false", StringComparison.OrdinalIgnoreCase))
{ {
continue; continue;
} }
@ -192,7 +192,7 @@ namespace MediaBrowser.Model.Dlna
if (MediaType == DlnaProfileType.Audio) if (MediaType == DlnaProfileType.Audio)
{ {
if (StringHelper.EqualsIgnoreCase(SubProtocol, "hls")) if (string.Equals(SubProtocol, "hls", StringComparison.OrdinalIgnoreCase))
{ {
return string.Format("{0}/audio/{1}/master.m3u8?{2}", baseUrl, ItemId, queryString); return string.Format("{0}/audio/{1}/master.m3u8?{2}", baseUrl, ItemId, queryString);
} }
@ -200,7 +200,7 @@ namespace MediaBrowser.Model.Dlna
return string.Format("{0}/audio/{1}/stream{2}?{3}", baseUrl, ItemId, extension, queryString); return string.Format("{0}/audio/{1}/stream{2}?{3}", baseUrl, ItemId, extension, queryString);
} }
if (StringHelper.EqualsIgnoreCase(SubProtocol, "hls")) if (string.Equals(SubProtocol, "hls", StringComparison.OrdinalIgnoreCase))
{ {
return string.Format("{0}/videos/{1}/master.m3u8?{2}", baseUrl, ItemId, queryString); return string.Format("{0}/videos/{1}/master.m3u8?{2}", baseUrl, ItemId, queryString);
} }
@ -237,7 +237,7 @@ namespace MediaBrowser.Model.Dlna
long startPositionTicks = item.StartPositionTicks; long startPositionTicks = item.StartPositionTicks;
var isHls = StringHelper.EqualsIgnoreCase(item.SubProtocol, "hls"); var isHls = string.Equals(item.SubProtocol, "hls", StringComparison.OrdinalIgnoreCase);
if (isHls) if (isHls)
{ {
@ -370,7 +370,7 @@ namespace MediaBrowser.Model.Dlna
var list = new List<SubtitleStreamInfo>(); var list = new List<SubtitleStreamInfo>();
// HLS will preserve timestamps so we can just grab the full subtitle stream // HLS will preserve timestamps so we can just grab the full subtitle stream
long startPositionTicks = StringHelper.EqualsIgnoreCase(SubProtocol, "hls") long startPositionTicks = string.Equals(SubProtocol, "hls", StringComparison.OrdinalIgnoreCase)
? 0 ? 0
: (PlayMethod == PlayMethod.Transcode && !CopyTimestamps ? StartPositionTicks : 0); : (PlayMethod == PlayMethod.Transcode && !CopyTimestamps ? StartPositionTicks : 0);
@ -435,7 +435,7 @@ namespace MediaBrowser.Model.Dlna
if (info.DeliveryMethod == SubtitleDeliveryMethod.External) if (info.DeliveryMethod == SubtitleDeliveryMethod.External)
{ {
if (MediaSource.Protocol == MediaProtocol.File || !StringHelper.EqualsIgnoreCase(stream.Codec, subtitleProfile.Format) || !stream.IsExternal) if (MediaSource.Protocol == MediaProtocol.File || !string.Equals(stream.Codec, subtitleProfile.Format, StringComparison.OrdinalIgnoreCase) || !stream.IsExternal)
{ {
info.Url = string.Format("{0}/Videos/{1}/{2}/Subtitles/{3}/{4}/Stream.{5}", info.Url = string.Format("{0}/Videos/{1}/{2}/Subtitles/{3}/{4}/Stream.{5}",
baseUrl, baseUrl,
@ -802,7 +802,7 @@ namespace MediaBrowser.Model.Dlna
foreach (string codec in AudioCodecs) foreach (string codec in AudioCodecs)
{ {
if (StringHelper.EqualsIgnoreCase(codec, inputCodec)) if (string.Equals(codec, inputCodec, StringComparison.OrdinalIgnoreCase))
{ {
return string.IsNullOrEmpty(codec) ? new string[] { } : new[] { codec }; return string.IsNullOrEmpty(codec) ? new string[] { } : new[] { codec };
} }
@ -827,7 +827,7 @@ namespace MediaBrowser.Model.Dlna
foreach (string codec in VideoCodecs) foreach (string codec in VideoCodecs)
{ {
if (StringHelper.EqualsIgnoreCase(codec, inputCodec)) if (string.Equals(codec, inputCodec, StringComparison.OrdinalIgnoreCase))
{ {
return string.IsNullOrEmpty(codec) ? new string[] { } : new[] { codec }; return string.IsNullOrEmpty(codec) ? new string[] { } : new[] { codec };
} }
@ -884,7 +884,7 @@ namespace MediaBrowser.Model.Dlna
{ {
get get
{ {
var defaultValue = StringHelper.EqualsIgnoreCase(Container, "m2ts") var defaultValue = string.Equals(Container, "m2ts", StringComparison.OrdinalIgnoreCase)
? TransportStreamTimestamp.Valid ? TransportStreamTimestamp.Valid
: TransportStreamTimestamp.None; : TransportStreamTimestamp.None;

View File

@ -88,11 +88,11 @@ namespace MediaBrowser.Model.Entities
{ {
attributes.Add(StringHelper.FirstToUpper(Language)); attributes.Add(StringHelper.FirstToUpper(Language));
} }
if (!string.IsNullOrEmpty(Codec) && !StringHelper.EqualsIgnoreCase(Codec, "dca")) if (!string.IsNullOrEmpty(Codec) && !string.Equals(Codec, "dca", StringComparison.OrdinalIgnoreCase))
{ {
attributes.Add(AudioCodec.GetFriendlyName(Codec)); attributes.Add(AudioCodec.GetFriendlyName(Codec));
} }
else if (!string.IsNullOrEmpty(Profile) && !StringHelper.EqualsIgnoreCase(Profile, "lc")) else if (!string.IsNullOrEmpty(Profile) && !string.Equals(Profile, "lc", StringComparison.OrdinalIgnoreCase))
{ {
attributes.Add(Profile); attributes.Add(Profile);
} }
@ -394,8 +394,8 @@ namespace MediaBrowser.Model.Entities
return codec.IndexOf("pgs", StringComparison.OrdinalIgnoreCase) == -1 && return codec.IndexOf("pgs", StringComparison.OrdinalIgnoreCase) == -1 &&
codec.IndexOf("dvd", StringComparison.OrdinalIgnoreCase) == -1 && codec.IndexOf("dvd", StringComparison.OrdinalIgnoreCase) == -1 &&
codec.IndexOf("dvbsub", StringComparison.OrdinalIgnoreCase) == -1 && codec.IndexOf("dvbsub", StringComparison.OrdinalIgnoreCase) == -1 &&
!StringHelper.EqualsIgnoreCase(codec, "sub") && !string.Equals(codec, "sub", StringComparison.OrdinalIgnoreCase) &&
!StringHelper.EqualsIgnoreCase(codec, "dvb_subtitle"); !string.Equals(codec, "dvb_subtitle", StringComparison.OrdinalIgnoreCase);
} }
public bool SupportsSubtitleConversionTo(string toCodec) public bool SupportsSubtitleConversionTo(string toCodec)
@ -408,21 +408,21 @@ namespace MediaBrowser.Model.Entities
var fromCodec = Codec; var fromCodec = Codec;
// Can't convert from this // Can't convert from this
if (StringHelper.EqualsIgnoreCase(fromCodec, "ass")) if (string.Equals(fromCodec, "ass", StringComparison.OrdinalIgnoreCase))
{ {
return false; return false;
} }
if (StringHelper.EqualsIgnoreCase(fromCodec, "ssa")) if (string.Equals(fromCodec, "ssa", StringComparison.OrdinalIgnoreCase))
{ {
return false; return false;
} }
// Can't convert to this // Can't convert to this
if (StringHelper.EqualsIgnoreCase(toCodec, "ass")) if (string.Equals(toCodec, "ass", StringComparison.OrdinalIgnoreCase))
{ {
return false; return false;
} }
if (StringHelper.EqualsIgnoreCase(toCodec, "ssa")) if (string.Equals(toCodec, "ssa", StringComparison.OrdinalIgnoreCase))
{ {
return false; return false;
} }

View File

@ -2,6 +2,7 @@ using System;
namespace MediaBrowser.Model.Extensions namespace MediaBrowser.Model.Extensions
{ {
// TODO: @bond remove
public static class ListHelper public static class ListHelper
{ {
public static bool ContainsIgnoreCase(string[] list, string value) public static bool ContainsIgnoreCase(string[] list, string value)

View File

@ -1,57 +1,38 @@
using System;
using System.Text;
namespace MediaBrowser.Model.Extensions namespace MediaBrowser.Model.Extensions
{ {
/// <summary> /// <summary>
/// Isolating these helpers allow this entire project to be easily converted to Java /// Helper methods for manipulating strings.
/// </summary> /// </summary>
public static class StringHelper public static class StringHelper
{ {
/// <summary> /// <summary>
/// Equalses the ignore case. /// Returns the string with the first character as uppercase.
/// </summary> /// </summary>
/// <param name="str1">The STR1.</param> /// <param name="str">The input string.</param>
/// <param name="str2">The STR2.</param> /// <returns>The string with the first character as uppercase.</returns>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public static string FirstToUpper(string str)
public static bool EqualsIgnoreCase(string str1, string str2)
{ {
return string.Equals(str1, str2, StringComparison.OrdinalIgnoreCase); if (string.IsNullOrEmpty(str))
{
return string.Empty;
} }
/// <summary> if (char.IsUpper(str[0]))
/// Replaces the specified STR.
/// </summary>
/// <param name="str">The STR.</param>
/// <param name="oldValue">The old value.</param>
/// <param name="newValue">The new value.</param>
/// <param name="comparison">The comparison.</param>
/// <returns>System.String.</returns>
public static string Replace(this string str, string oldValue, string newValue, StringComparison comparison)
{ {
var sb = new StringBuilder(); return str;
var previousIndex = 0;
var index = str.IndexOf(oldValue, comparison);
while (index != -1)
{
sb.Append(str.Substring(previousIndex, index - previousIndex));
sb.Append(newValue);
index += oldValue.Length;
previousIndex = index;
index = str.IndexOf(oldValue, index, comparison);
} }
sb.Append(str.Substring(previousIndex)); return string.Create(
str.Length,
return sb.ToString(); str,
} (chars, buf) =>
public static string FirstToUpper(this string str)
{ {
return string.IsNullOrEmpty(str) ? string.Empty : str.Substring(0, 1).ToUpperInvariant() + str.Substring(1); chars[0] = char.ToUpperInvariant(buf[0]);
for (int i = 1; i < chars.Length; i++)
{
chars[i] = buf[i];
}
});
} }
} }
} }

View File

@ -8,7 +8,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.1</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup> </PropertyGroup>

View File

@ -165,20 +165,20 @@ namespace MediaBrowser.Model.Net
} }
// Type text // Type text
if (StringHelper.EqualsIgnoreCase(ext, ".html") if (string.Equals(ext, ".html", StringComparison.OrdinalIgnoreCase)
|| StringHelper.EqualsIgnoreCase(ext, ".htm")) || string.Equals(ext, ".htm", StringComparison.OrdinalIgnoreCase))
{ {
return "text/html; charset=UTF-8"; return "text/html; charset=UTF-8";
} }
if (StringHelper.EqualsIgnoreCase(ext, ".log") if (string.Equals(ext, ".log", StringComparison.OrdinalIgnoreCase)
|| StringHelper.EqualsIgnoreCase(ext, ".srt")) || string.Equals(ext, ".srt", StringComparison.OrdinalIgnoreCase))
{ {
return "text/plain"; return "text/plain";
} }
// Misc // Misc
if (StringHelper.EqualsIgnoreCase(ext, ".dll")) if (string.Equals(ext, ".dll", StringComparison.OrdinalIgnoreCase))
{ {
return "application/octet-stream"; return "application/octet-stream";
} }

View File

@ -79,7 +79,7 @@ namespace MediaBrowser.Model.Notifications
{ {
foreach (NotificationOption i in Options) foreach (NotificationOption i in Options)
{ {
if (StringHelper.EqualsIgnoreCase(type, i.Type)) return i; if (string.Equals(type, i.Type, StringComparison.OrdinalIgnoreCase)) return i;
} }
return null; return null;
} }