Fix more analyzer warnings

This commit is contained in:
Bond_009 2019-01-27 12:03:43 +01:00
parent ee89236fe8
commit a709cbdc64
49 changed files with 285 additions and 256 deletions

View File

@ -236,7 +236,9 @@ namespace Emby.Dlna.Api
public object Get(GetIcon request) public object Get(GetIcon request)
{ {
var contentType = "image/" + Path.GetExtension(request.Filename).TrimStart('.').ToLower(); var contentType = "image/" + Path.GetExtension(request.Filename)
.TrimStart('.')
.ToLowerInvariant();
var cacheLength = TimeSpan.FromDays(365); var cacheLength = TimeSpan.FromDays(365);
var cacheKey = Request.RawUrl.GetMD5(); var cacheKey = Request.RawUrl.GetMD5();

View File

@ -265,7 +265,7 @@ namespace Emby.Dlna.Didl
// <sec:CaptionInfo sec:type="srt">http://192.168.1.3:9999/video.srt</sec:CaptionInfo> // <sec:CaptionInfo sec:type="srt">http://192.168.1.3:9999/video.srt</sec:CaptionInfo>
writer.WriteStartElement("sec", "CaptionInfoEx", null); writer.WriteStartElement("sec", "CaptionInfoEx", null);
writer.WriteAttributeString("sec", "type", null, info.Format.ToLower()); writer.WriteAttributeString("sec", "type", null, info.Format.ToLowerInvariant());
writer.WriteString(info.Url); writer.WriteString(info.Url);
writer.WriteFullEndElement(); writer.WriteFullEndElement();
@ -282,7 +282,7 @@ namespace Emby.Dlna.Didl
else else
{ {
writer.WriteStartElement(string.Empty, "res", NS_DIDL); writer.WriteStartElement(string.Empty, "res", NS_DIDL);
var protocolInfo = string.Format("http-get:*:text/{0}:*", info.Format.ToLower()); var protocolInfo = string.Format("http-get:*:text/{0}:*", info.Format.ToLowerInvariant());
writer.WriteAttributeString("protocolInfo", protocolInfo); writer.WriteAttributeString("protocolInfo", protocolInfo);
writer.WriteString(info.Url); writer.WriteString(info.Url);
@ -844,7 +844,7 @@ namespace Emby.Dlna.Didl
// var type = types.FirstOrDefault(i => string.Equals(i, actor.Type, StringComparison.OrdinalIgnoreCase) || string.Equals(i, actor.Role, StringComparison.OrdinalIgnoreCase)) // var type = types.FirstOrDefault(i => string.Equals(i, actor.Type, StringComparison.OrdinalIgnoreCase) || string.Equals(i, actor.Role, StringComparison.OrdinalIgnoreCase))
// ?? PersonType.Actor; // ?? PersonType.Actor;
// AddValue(writer, "upnp", type.ToLower(), actor.Name, NS_UPNP); // AddValue(writer, "upnp", type.ToLowerInvariant(), actor.Name, NS_UPNP);
// index++; // index++;
@ -1147,7 +1147,7 @@ namespace Emby.Dlna.Didl
if (stubType.HasValue) if (stubType.HasValue)
{ {
id = stubType.Value.ToString().ToLower() + "_" + id; id = stubType.Value.ToString().ToLowerInvariant() + "_" + id;
} }
return id; return id;

View File

@ -300,7 +300,7 @@ namespace Emby.Dlna
profile = ReserializeProfile(tempProfile); profile = ReserializeProfile(tempProfile);
profile.Id = path.ToLower().GetMD5().ToString("N"); profile.Id = path.ToLowerInvariant().GetMD5().ToString("N");
_profiles[path] = new Tuple<InternalProfileInfo, DeviceProfile>(GetInternalProfileInfo(_fileSystem.GetFileInfo(path), type), profile); _profiles[path] = new Tuple<InternalProfileInfo, DeviceProfile>(GetInternalProfileInfo(_fileSystem.GetFileInfo(path), type), profile);
@ -352,7 +352,7 @@ namespace Emby.Dlna
Info = new DeviceProfileInfo Info = new DeviceProfileInfo
{ {
Id = file.FullName.ToLower().GetMD5().ToString("N"), Id = file.FullName.ToLowerInvariant().GetMD5().ToString("N"),
Name = _fileSystem.GetFileNameWithoutExtension(file), Name = _fileSystem.GetFileNameWithoutExtension(file),
Type = type Type = type
} }
@ -506,7 +506,7 @@ namespace Emby.Dlna
? ImageFormat.Png ? ImageFormat.Png
: ImageFormat.Jpg; : ImageFormat.Jpg;
var resource = GetType().Namespace + ".Images." + filename.ToLower(); var resource = GetType().Namespace + ".Images." + filename.ToLowerInvariant();
return new ImageStream return new ImageStream
{ {

View File

@ -263,7 +263,7 @@ namespace Emby.Dlna.Main
var fullService = "urn:schemas-upnp-org:device:MediaServer:1"; var fullService = "urn:schemas-upnp-org:device:MediaServer:1";
_logger.LogInformation("Registering publisher for {0} on {1}", fullService, address.ToString()); _logger.LogInformation("Registering publisher for {0} on {1}", fullService, address);
var descriptorUri = "/dlna/" + udn + "/description.xml"; var descriptorUri = "/dlna/" + udn + "/description.xml";
var uri = new Uri(_appHost.GetLocalApiUrl(address) + descriptorUri); var uri = new Uri(_appHost.GetLocalApiUrl(address) + descriptorUri);

View File

@ -902,54 +902,75 @@ namespace Emby.Dlna.PlayTo
var name = document.Descendants(uPnpNamespaces.ud.GetName("friendlyName")).FirstOrDefault(); var name = document.Descendants(uPnpNamespaces.ud.GetName("friendlyName")).FirstOrDefault();
if (name != null && !string.IsNullOrWhiteSpace(name.Value)) if (name != null && !string.IsNullOrWhiteSpace(name.Value))
{
friendlyNames.Add(name.Value); friendlyNames.Add(name.Value);
}
var room = document.Descendants(uPnpNamespaces.ud.GetName("roomName")).FirstOrDefault(); var room = document.Descendants(uPnpNamespaces.ud.GetName("roomName")).FirstOrDefault();
if (room != null && !string.IsNullOrWhiteSpace(room.Value)) if (room != null && !string.IsNullOrWhiteSpace(room.Value))
{
friendlyNames.Add(room.Value); friendlyNames.Add(room.Value);
}
deviceProperties.Name = string.Join(" ", friendlyNames.ToArray()); deviceProperties.Name = string.Join(" ", friendlyNames);
var model = document.Descendants(uPnpNamespaces.ud.GetName("modelName")).FirstOrDefault(); var model = document.Descendants(uPnpNamespaces.ud.GetName("modelName")).FirstOrDefault();
if (model != null) if (model != null)
{
deviceProperties.ModelName = model.Value; deviceProperties.ModelName = model.Value;
}
var modelNumber = document.Descendants(uPnpNamespaces.ud.GetName("modelNumber")).FirstOrDefault(); var modelNumber = document.Descendants(uPnpNamespaces.ud.GetName("modelNumber")).FirstOrDefault();
if (modelNumber != null) if (modelNumber != null)
{
deviceProperties.ModelNumber = modelNumber.Value; deviceProperties.ModelNumber = modelNumber.Value;
}
var uuid = document.Descendants(uPnpNamespaces.ud.GetName("UDN")).FirstOrDefault(); var uuid = document.Descendants(uPnpNamespaces.ud.GetName("UDN")).FirstOrDefault();
if (uuid != null) if (uuid != null)
{
deviceProperties.UUID = uuid.Value; deviceProperties.UUID = uuid.Value;
}
var manufacturer = document.Descendants(uPnpNamespaces.ud.GetName("manufacturer")).FirstOrDefault(); var manufacturer = document.Descendants(uPnpNamespaces.ud.GetName("manufacturer")).FirstOrDefault();
if (manufacturer != null) if (manufacturer != null)
{
deviceProperties.Manufacturer = manufacturer.Value; deviceProperties.Manufacturer = manufacturer.Value;
}
var manufacturerUrl = document.Descendants(uPnpNamespaces.ud.GetName("manufacturerURL")).FirstOrDefault(); var manufacturerUrl = document.Descendants(uPnpNamespaces.ud.GetName("manufacturerURL")).FirstOrDefault();
if (manufacturerUrl != null) if (manufacturerUrl != null)
{
deviceProperties.ManufacturerUrl = manufacturerUrl.Value; deviceProperties.ManufacturerUrl = manufacturerUrl.Value;
}
var presentationUrl = document.Descendants(uPnpNamespaces.ud.GetName("presentationURL")).FirstOrDefault(); var presentationUrl = document.Descendants(uPnpNamespaces.ud.GetName("presentationURL")).FirstOrDefault();
if (presentationUrl != null) if (presentationUrl != null)
{
deviceProperties.PresentationUrl = presentationUrl.Value; deviceProperties.PresentationUrl = presentationUrl.Value;
}
var modelUrl = document.Descendants(uPnpNamespaces.ud.GetName("modelURL")).FirstOrDefault(); var modelUrl = document.Descendants(uPnpNamespaces.ud.GetName("modelURL")).FirstOrDefault();
if (modelUrl != null) if (modelUrl != null)
{
deviceProperties.ModelUrl = modelUrl.Value; deviceProperties.ModelUrl = modelUrl.Value;
}
var serialNumber = document.Descendants(uPnpNamespaces.ud.GetName("serialNumber")).FirstOrDefault(); var serialNumber = document.Descendants(uPnpNamespaces.ud.GetName("serialNumber")).FirstOrDefault();
if (serialNumber != null) if (serialNumber != null)
{
deviceProperties.SerialNumber = serialNumber.Value; deviceProperties.SerialNumber = serialNumber.Value;
}
var modelDescription = document.Descendants(uPnpNamespaces.ud.GetName("modelDescription")).FirstOrDefault(); var modelDescription = document.Descendants(uPnpNamespaces.ud.GetName("modelDescription")).FirstOrDefault();
if (modelDescription != null) if (modelDescription != null)
{
deviceProperties.ModelDescription = modelDescription.Value; deviceProperties.ModelDescription = modelDescription.Value;
}
deviceProperties.BaseUrl = string.Format("http://{0}:{1}", url.Host, url.Port); deviceProperties.BaseUrl = string.Format("http://{0}:{1}", url.Host, url.Port);
var icon = document.Descendants(uPnpNamespaces.ud.GetName("icon")).FirstOrDefault(); var icon = document.Descendants(uPnpNamespaces.ud.GetName("icon")).FirstOrDefault();
if (icon != null) if (icon != null)
{ {
deviceProperties.Icon = CreateIcon(icon); deviceProperties.Icon = CreateIcon(icon);
@ -958,12 +979,16 @@ namespace Emby.Dlna.PlayTo
foreach (var services in document.Descendants(uPnpNamespaces.ud.GetName("serviceList"))) foreach (var services in document.Descendants(uPnpNamespaces.ud.GetName("serviceList")))
{ {
if (services == null) if (services == null)
{
continue; continue;
}
var servicesList = services.Descendants(uPnpNamespaces.ud.GetName("service")); var servicesList = services.Descendants(uPnpNamespaces.ud.GetName("service"));
if (servicesList == null) if (servicesList == null)
{
continue; continue;
}
foreach (var element in servicesList) foreach (var element in servicesList)
{ {
@ -1065,13 +1090,10 @@ namespace Emby.Dlna.PlayTo
private void OnPlaybackStart(uBaseObject mediaInfo) private void OnPlaybackStart(uBaseObject mediaInfo)
{ {
if (PlaybackStart != null) PlaybackStart?.Invoke(this, new PlaybackStartEventArgs
{ {
PlaybackStart.Invoke(this, new PlaybackStartEventArgs MediaInfo = mediaInfo
{ });
MediaInfo = mediaInfo
});
}
} }
private void OnPlaybackProgress(uBaseObject mediaInfo) private void OnPlaybackProgress(uBaseObject mediaInfo)
@ -1082,36 +1104,28 @@ namespace Emby.Dlna.PlayTo
return; return;
} }
if (PlaybackProgress != null) PlaybackProgress?.Invoke(this, new PlaybackProgressEventArgs
{ {
PlaybackProgress.Invoke(this, new PlaybackProgressEventArgs MediaInfo = mediaInfo
{ });
MediaInfo = mediaInfo
});
}
} }
private void OnPlaybackStop(uBaseObject mediaInfo) private void OnPlaybackStop(uBaseObject mediaInfo)
{ {
if (PlaybackStopped != null)
PlaybackStopped?.Invoke(this, new PlaybackStoppedEventArgs
{ {
PlaybackStopped.Invoke(this, new PlaybackStoppedEventArgs MediaInfo = mediaInfo
{ });
MediaInfo = mediaInfo
});
}
} }
private void OnMediaChanged(uBaseObject old, uBaseObject newMedia) private void OnMediaChanged(uBaseObject old, uBaseObject newMedia)
{ {
if (MediaChanged != null) MediaChanged?.Invoke(this, new MediaChangedEventArgs
{ {
MediaChanged.Invoke(this, new MediaChangedEventArgs OldMediaInfo = old,
{ NewMediaInfo = newMedia
OldMediaInfo = old, });
NewMediaInfo = newMedia
});
}
} }
#region IDisposable #region IDisposable

View File

@ -107,19 +107,19 @@ namespace Emby.Dlna.Server
'&' '&'
}; };
private static readonly string[] s_escapeStringPairs = new string[] private static readonly string[] s_escapeStringPairs = new[]
{ {
"<", "<",
"&lt;", "&lt;",
">", ">",
"&gt;", "&gt;",
"\"", "\"",
"&quot;", "&quot;",
"'", "'",
"&apos;", "&apos;",
"&", "&",
"&amp;" "&amp;"
}; };
private static string GetEscapeSequence(char c) private static string GetEscapeSequence(char c)
{ {
@ -133,7 +133,7 @@ namespace Emby.Dlna.Server
return result; return result;
} }
} }
return c.ToString(); return c.ToString(CultureInfo.InvariantCulture);
} }
/// <summary>Replaces invalid XML characters in a string with their valid XML equivalent.</summary> /// <summary>Replaces invalid XML characters in a string with their valid XML equivalent.</summary>
@ -145,6 +145,7 @@ namespace Emby.Dlna.Server
{ {
return null; return null;
} }
StringBuilder stringBuilder = null; StringBuilder stringBuilder = null;
int length = str.Length; int length = str.Length;
int num = 0; int num = 0;
@ -230,9 +231,9 @@ namespace Emby.Dlna.Server
var serverName = new string(characters); var serverName = new string(characters);
var name = (_profile.FriendlyName ?? string.Empty).Replace("${HostName}", serverName, StringComparison.OrdinalIgnoreCase); var name = _profile.FriendlyName?.Replace("${HostName}", serverName, StringComparison.OrdinalIgnoreCase);
return name; return name ?? string.Empty;
} }
private void AppendIconList(StringBuilder builder) private void AppendIconList(StringBuilder builder)
@ -295,65 +296,62 @@ namespace Emby.Dlna.Server
} }
private IEnumerable<DeviceIcon> GetIcons() private IEnumerable<DeviceIcon> GetIcons()
{ => new[]
var list = new List<DeviceIcon>();
list.Add(new DeviceIcon
{ {
MimeType = "image/png", new DeviceIcon
Depth = "24", {
Width = 240, MimeType = "image/png",
Height = 240, Depth = "24",
Url = "icons/logo240.png" Width = 240,
}); Height = 240,
Url = "icons/logo240.png"
},
list.Add(new DeviceIcon new DeviceIcon
{ {
MimeType = "image/jpeg", MimeType = "image/jpeg",
Depth = "24", Depth = "24",
Width = 240, Width = 240,
Height = 240, Height = 240,
Url = "icons/logo240.jpg" Url = "icons/logo240.jpg"
}); },
list.Add(new DeviceIcon new DeviceIcon
{ {
MimeType = "image/png", MimeType = "image/png",
Depth = "24", Depth = "24",
Width = 120, Width = 120,
Height = 120, Height = 120,
Url = "icons/logo120.png" Url = "icons/logo120.png"
}); },
list.Add(new DeviceIcon new DeviceIcon
{ {
MimeType = "image/jpeg", MimeType = "image/jpeg",
Depth = "24", Depth = "24",
Width = 120, Width = 120,
Height = 120, Height = 120,
Url = "icons/logo120.jpg" Url = "icons/logo120.jpg"
}); },
list.Add(new DeviceIcon new DeviceIcon
{ {
MimeType = "image/png", MimeType = "image/png",
Depth = "24", Depth = "24",
Width = 48, Width = 48,
Height = 48, Height = 48,
Url = "icons/logo48.png" Url = "icons/logo48.png"
}); },
list.Add(new DeviceIcon new DeviceIcon
{ {
MimeType = "image/jpeg", MimeType = "image/jpeg",
Depth = "24", Depth = "24",
Width = 48, Width = 48,
Height = 48, Height = 48,
Url = "icons/logo48.jpg" Url = "icons/logo48.jpg"
}); }
};
return list;
}
private IEnumerable<DeviceService> GetServices() private IEnumerable<DeviceService> GetServices()
{ {

View File

@ -144,7 +144,7 @@ namespace Emby.Drawing
private static readonly string[] TransparentImageTypes = new string[] { ".png", ".webp", ".gif" }; private static readonly string[] TransparentImageTypes = new string[] { ".png", ".webp", ".gif" };
public bool SupportsTransparency(string path) public bool SupportsTransparency(string path)
=> TransparentImageTypes.Contains(Path.GetExtension(path).ToLower()); => TransparentImageTypes.Contains(Path.GetExtension(path).ToLowerInvariant());
public async Task<(string path, string mimeType, DateTime dateModified)> ProcessImage(ImageProcessingOptions options) public async Task<(string path, string mimeType, DateTime dateModified)> ProcessImage(ImageProcessingOptions options)
{ {
@ -374,7 +374,7 @@ namespace Emby.Drawing
filename += "v=" + Version; filename += "v=" + Version;
return GetCachePath(ResizedImageCachePath, filename, "." + format.ToString().ToLower()); return GetCachePath(ResizedImageCachePath, filename, "." + format.ToString().ToLowerInvariant());
} }
public ImageDimensions GetImageSize(BaseItem item, ItemImageInfo info) public ImageDimensions GetImageSize(BaseItem item, ItemImageInfo info)

View File

@ -121,7 +121,7 @@ namespace IsoMounter
path, path,
Path.GetExtension(path), Path.GetExtension(path),
EnvironmentInfo.OperatingSystem, EnvironmentInfo.OperatingSystem,
ExecutablesAvailable.ToString() ExecutablesAvailable
); );
if (ExecutablesAvailable) if (ExecutablesAvailable)
@ -183,7 +183,7 @@ namespace IsoMounter
_logger.LogInformation( _logger.LogInformation(
"[{0}] Disposing [{1}].", "[{0}] Disposing [{1}].",
Name, Name,
disposing.ToString() disposing
); );
if (disposing) if (disposing)
@ -229,9 +229,8 @@ namespace IsoMounter
var uid = getuid(); var uid = getuid();
_logger.LogDebug( _logger.LogDebug(
"[{0}] Our current UID is [{1}], GetUserId() returned [{2}].", "[{0}] GetUserId() returned [{2}].",
Name, Name,
uid.ToString(),
uid uid
); );

View File

@ -218,7 +218,7 @@ namespace Emby.Server.Implementations.AppBase
private string GetConfigurationFile(string key) private string GetConfigurationFile(string key)
{ {
return Path.Combine(CommonApplicationPaths.ConfigurationDirectoryPath, key.ToLower() + ".xml"); return Path.Combine(CommonApplicationPaths.ConfigurationDirectoryPath, key.ToLowerInvariant() + ".xml");
} }
public object GetConfiguration(string key) public object GetConfiguration(string key)

View File

@ -3905,7 +3905,7 @@ namespace Emby.Server.Implementations.Data
// lowercase this because SortName is stored as lowercase // lowercase this because SortName is stored as lowercase
if (statement != null) if (statement != null)
{ {
statement.TryBind("@NameStartsWithOrGreater", query.NameStartsWithOrGreater.ToLower()); statement.TryBind("@NameStartsWithOrGreater", query.NameStartsWithOrGreater.ToLowerInvariant());
} }
} }
if (!string.IsNullOrWhiteSpace(query.NameLessThan)) if (!string.IsNullOrWhiteSpace(query.NameLessThan))
@ -3914,7 +3914,7 @@ namespace Emby.Server.Implementations.Data
// lowercase this because SortName is stored as lowercase // lowercase this because SortName is stored as lowercase
if (statement != null) if (statement != null)
{ {
statement.TryBind("@NameLessThan", query.NameLessThan.ToLower()); statement.TryBind("@NameLessThan", query.NameLessThan.ToLowerInvariant());
} }
} }
@ -4822,7 +4822,7 @@ namespace Emby.Server.Implementations.Data
return value; return value;
} }
return value.RemoveDiacritics().ToLower(); return value.RemoveDiacritics().ToLowerInvariant();
} }
private bool EnableGroupByPresentationUniqueKey(InternalItemsQuery query) private bool EnableGroupByPresentationUniqueKey(InternalItemsQuery query)

View File

@ -264,7 +264,7 @@ namespace Emby.Server.Implementations.HttpClientManager
} }
var url = options.Url; var url = options.Url;
var urlHash = url.ToLower().GetMD5().ToString("N"); var urlHash = url.ToLowerInvariant().GetMD5().ToString("N");
var responseCachePath = Path.Combine(_appPaths.CachePath, "httpclient", urlHash); var responseCachePath = Path.Combine(_appPaths.CachePath, "httpclient", urlHash);
@ -384,11 +384,11 @@ namespace Emby.Server.Implementations.HttpClientManager
{ {
if (options.LogRequestAsDebug) if (options.LogRequestAsDebug)
{ {
_logger.LogDebug("HttpClientManager {0}: {1}", httpMethod.ToUpper(), options.Url); _logger.LogDebug("HttpClientManager {0}: {1}", httpMethod.ToUpper(CultureInfo.CurrentCulture), options.Url);
} }
else else
{ {
_logger.LogInformation("HttpClientManager {0}: {1}", httpMethod.ToUpper(), options.Url); _logger.LogInformation("HttpClientManager {0}: {1}", httpMethod.ToUpper(CultureInfo.CurrentCulture), options.Url);
} }
} }

View File

@ -394,7 +394,7 @@ namespace Emby.Server.Implementations.HttpServer
{ {
return contentType == null return contentType == null
? null ? null
: contentType.Split(';')[0].ToLower().Trim(); : contentType.Split(';')[0].ToLowerInvariant().Trim();
} }
private static string SerializeToXmlString(object from) private static string SerializeToXmlString(object from)

View File

@ -517,7 +517,7 @@ namespace Emby.Server.Implementations.Library
if (forceCaseInsensitive || !ConfigurationManager.Configuration.EnableCaseSensitiveItemIds) if (forceCaseInsensitive || !ConfigurationManager.Configuration.EnableCaseSensitiveItemIds)
{ {
key = key.ToLower(); key = key.ToLowerInvariant();
} }
key = type.FullName + key; key = type.FullName + key;

View File

@ -2193,7 +2193,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
if (lockData) if (lockData)
{ {
writer.WriteElementString("lockdata", true.ToString().ToLower()); writer.WriteElementString("lockdata", true.ToString(CultureInfo.InvariantCulture).ToLowerInvariant());
} }
if (item.CriticRating.HasValue) if (item.CriticRating.HasValue)

View File

@ -399,7 +399,7 @@ namespace Emby.Server.Implementations.LiveTv
{ {
var name = serviceName + externalId + InternalVersionNumber; var name = serviceName + externalId + InternalVersionNumber;
return _libraryManager.GetNewItemId(name.ToLower(), typeof(LiveTvChannel)); return _libraryManager.GetNewItemId(name.ToLowerInvariant(), typeof(LiveTvChannel));
} }
private const string ServiceName = "Emby"; private const string ServiceName = "Emby";
@ -407,21 +407,21 @@ namespace Emby.Server.Implementations.LiveTv
{ {
var name = ServiceName + externalId + InternalVersionNumber; var name = ServiceName + externalId + InternalVersionNumber;
return name.ToLower().GetMD5().ToString("N"); return name.ToLowerInvariant().GetMD5().ToString("N");
} }
public Guid GetInternalSeriesTimerId(string externalId) public Guid GetInternalSeriesTimerId(string externalId)
{ {
var name = ServiceName + externalId + InternalVersionNumber; var name = ServiceName + externalId + InternalVersionNumber;
return name.ToLower().GetMD5(); return name.ToLowerInvariant().GetMD5();
} }
public Guid GetInternalProgramId(string externalId) public Guid GetInternalProgramId(string externalId)
{ {
var name = ServiceName + externalId + InternalVersionNumber; var name = ServiceName + externalId + InternalVersionNumber;
return _libraryManager.GetNewItemId(name.ToLower(), typeof(LiveTvProgram)); return _libraryManager.GetNewItemId(name.ToLowerInvariant(), typeof(LiveTvProgram));
} }
public async Task<TimerInfo> GetTimerInfo(TimerInfoDto dto, bool isNew, LiveTvManager liveTv, CancellationToken cancellationToken) public async Task<TimerInfo> GetTimerInfo(TimerInfoDto dto, bool isNew, LiveTvManager liveTv, CancellationToken cancellationToken)

View File

@ -492,11 +492,11 @@ namespace Emby.Server.Implementations.Localization
if (parts.Length == 2) if (parts.Length == 2)
{ {
culture = parts[0].ToLower() + "-" + parts[1].ToUpper(); culture = parts[0].ToLowerInvariant() + "-" + parts[1].ToUpperInvariant();
} }
else else
{ {
culture = culture.ToLower(); culture = culture.ToLowerInvariant();
} }
return culture + ".json"; return culture + ".json";

View File

@ -45,7 +45,7 @@ namespace Emby.Server.Implementations.Services
{ {
return contentType == null return contentType == null
? null ? null
: contentType.Split(';')[0].ToLower().Trim(); : contentType.Split(';')[0].ToLowerInvariant().Trim();
} }
} }

View File

@ -98,7 +98,7 @@ namespace Emby.Server.Implementations.Services
return Task.FromResult(response); return Task.FromResult(response);
} }
var expectedMethodName = actionName.Substring(0, 1) + actionName.Substring(1).ToLower(); var expectedMethodName = actionName.Substring(0, 1) + actionName.Substring(1).ToLowerInvariant();
throw new NotImplementedException(string.Format("Could not find method named {1}({0}) or Any({0}) on Service {2}", requestDto.GetType().GetMethodName(), expectedMethodName, serviceType.GetMethodName())); throw new NotImplementedException(string.Format("Could not find method named {1}({0}) or Any({0}) on Service {2}", requestDto.GetType().GetMethodName(), expectedMethodName, serviceType.GetMethodName()));
} }

View File

@ -11,7 +11,7 @@ namespace Emby.Server.Implementations.Services
public static string Key(Type serviceType, string method, string requestDtoName) public static string Key(Type serviceType, string method, string requestDtoName)
{ {
return serviceType.FullName + " " + method.ToUpper() + " " + requestDtoName; return serviceType.FullName + " " + method.ToUpperInvariant() + " " + requestDtoName;
} }
} }
} }

View File

@ -60,7 +60,7 @@ namespace Emby.Server.Implementations.Services
public static string[] GetPathPartsForMatching(string pathInfo) public static string[] GetPathPartsForMatching(string pathInfo)
{ {
return pathInfo.ToLower().Split(new[] { PathSeperatorChar }, StringSplitOptions.RemoveEmptyEntries); return pathInfo.ToLowerInvariant().Split(new[] { PathSeperatorChar }, StringSplitOptions.RemoveEmptyEntries);
} }
public static List<string> GetFirstMatchHashKeys(string[] pathPartsForMatching) public static List<string> GetFirstMatchHashKeys(string[] pathPartsForMatching)
@ -104,7 +104,7 @@ namespace Emby.Server.Implementations.Services
this.Description = description; this.Description = description;
this.restPath = path; this.restPath = path;
this.Verbs = string.IsNullOrWhiteSpace(verbs) ? ServiceExecExtensions.AllVerbs : verbs.ToUpper().Split(new[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries); this.Verbs = string.IsNullOrWhiteSpace(verbs) ? ServiceExecExtensions.AllVerbs : verbs.ToUpperInvariant().Split(new[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);
var componentsList = new List<string>(); var componentsList = new List<string>();
@ -154,7 +154,7 @@ namespace Emby.Server.Implementations.Services
} }
else else
{ {
this.literalsToMatch[i] = component.ToLower(); this.literalsToMatch[i] = component.ToLowerInvariant();
if (firstLiteralMatch == null) if (firstLiteralMatch == null)
{ {
@ -189,7 +189,7 @@ namespace Emby.Server.Implementations.Services
foreach (var propertyInfo in GetSerializableProperties(RequestType)) foreach (var propertyInfo in GetSerializableProperties(RequestType))
{ {
var propertyName = propertyInfo.Name; var propertyName = propertyInfo.Name;
propertyNamesMap.Add(propertyName.ToLower(), propertyName); propertyNamesMap.Add(propertyName.ToLowerInvariant(), propertyName);
} }
} }
@ -483,7 +483,7 @@ namespace Emby.Server.Implementations.Services
continue; continue;
} }
if (!this.propertyNamesMap.TryGetValue(variableName.ToLower(), out var propertyNameOnRequest)) if (!this.propertyNamesMap.TryGetValue(variableName.ToLowerInvariant(), out var propertyNameOnRequest))
{ {
if (string.Equals("ignore", variableName, StringComparison.OrdinalIgnoreCase)) if (string.Equals("ignore", variableName, StringComparison.OrdinalIgnoreCase))
{ {

View File

@ -216,40 +216,28 @@ namespace Emby.Server.Implementations.Services
{ {
var responses = new Dictionary<string, SwaggerResponse> var responses = new Dictionary<string, SwaggerResponse>
{ {
{ "200", new SwaggerResponse { description = "OK" } }
}; };
responses["200"] = new SwaggerResponse var apiKeySecurity = new Dictionary<string, string[]>
{ {
description = "OK" { "api_key", Array.Empty<string>() }
}; };
var security = new List<Dictionary<string, string[]>>(); result[verb.ToLowerInvariant()] = new SwaggerMethod
var apiKeySecurity = new Dictionary<string, string[]>();
apiKeySecurity["api_key"] = Array.Empty<string>();
security.Add(apiKeySecurity);
result[verb.ToLower()] = new SwaggerMethod
{ {
summary = info.Summary, summary = info.Summary,
description = info.Description, description = info.Description,
produces = new[] produces = new[] { "application/json" },
{ consumes = new[] { "application/json" },
"application/json"
},
consumes = new[]
{
"application/json"
},
operationId = info.RequestType.Name, operationId = info.RequestType.Name,
tags = Array.Empty<string>(), tags = Array.Empty<string>(),
parameters = new SwaggerParam[] { }, parameters = Array.Empty<SwaggerParam>(),
responses = responses, responses = responses,
security = security.ToArray() security = new [] { apiKeySecurity }
}; };
} }

View File

@ -25,7 +25,7 @@ namespace Jellyfin.Drawing.Skia
throw new ArgumentNullException(nameof(outputPath)); throw new ArgumentNullException(nameof(outputPath));
} }
var ext = Path.GetExtension(outputPath).ToLower(); var ext = Path.GetExtension(outputPath).ToLowerInvariant();
if (ext == ".jpg" || ext == ".jpeg") if (ext == ".jpg" || ext == ".jpeg")
return SKEncodedImageFormat.Jpeg; return SKEncodedImageFormat.Jpeg;

View File

@ -360,13 +360,13 @@ namespace Jellyfin.SocketSharp
int len = buffer.Length; int len = buffer.Length;
if (dest_offset > len) if (dest_offset > len)
{ {
throw new ArgumentException("destination offset is beyond array size"); throw new ArgumentException("destination offset is beyond array size", nameof(dest_offset));
} }
// reordered to avoid possible integer overflow // reordered to avoid possible integer overflow
if (dest_offset > len - count) if (dest_offset > len - count)
{ {
throw new ArgumentException("Reading would overrun buffer"); throw new ArgumentException("Reading would overrun buffer", nameof(count));
} }
if (count > end - position) if (count > end - position)
@ -528,7 +528,7 @@ namespace Jellyfin.SocketSharp
} }
} }
class HttpMultipart private class HttpMultipart
{ {
public class Element public class Element
@ -543,19 +543,19 @@ namespace Jellyfin.SocketSharp
public override string ToString() public override string ToString()
{ {
return "ContentType " + ContentType + ", Name " + Name + ", Filename " + Filename + ", Start " + return "ContentType " + ContentType + ", Name " + Name + ", Filename " + Filename + ", Start " +
Start.ToString() + ", Length " + Length.ToString(); Start.ToString(CultureInfo.CurrentCulture) + ", Length " + Length.ToString(CultureInfo.CurrentCulture);
} }
} }
Stream data; private Stream data;
string boundary; private string boundary;
byte[] boundary_bytes; private byte[] boundary_bytes;
byte[] buffer; private byte[] buffer;
bool at_eof; private bool at_eof;
Encoding encoding; private Encoding encoding;
StringBuilder sb; private StringBuilder sb;
const byte LF = (byte)'\n', CR = (byte)'\r'; private const byte LF = (byte)'\n', CR = (byte)'\r';
// See RFC 2046 // See RFC 2046
// In the case of multipart entities, in which one or more different // In the case of multipart entities, in which one or more different
@ -610,7 +610,6 @@ namespace Jellyfin.SocketSharp
} }
return sb.ToString(); return sb.ToString();
} }
private static string GetContentDispositionAttribute(string l, string name) private static string GetContentDispositionAttribute(string l, string name)

View File

@ -29,12 +29,24 @@ namespace Jellyfin.SocketSharp
private static string GetHandlerPathIfAny(string listenerUrl) private static string GetHandlerPathIfAny(string listenerUrl)
{ {
if (listenerUrl == null) return null; if (listenerUrl == null)
{
return null;
}
var pos = listenerUrl.IndexOf("://", StringComparison.OrdinalIgnoreCase); var pos = listenerUrl.IndexOf("://", StringComparison.OrdinalIgnoreCase);
if (pos == -1) return null; if (pos == -1)
{
return null;
}
var startHostUrl = listenerUrl.Substring(pos + "://".Length); var startHostUrl = listenerUrl.Substring(pos + "://".Length);
var endPos = startHostUrl.IndexOf('/'); var endPos = startHostUrl.IndexOf('/');
if (endPos == -1) return null; if (endPos == -1)
{
return null;
}
var endHostUrl = startHostUrl.Substring(endPos + 1); var endHostUrl = startHostUrl.Substring(endPos + 1);
return string.IsNullOrEmpty(endHostUrl) ? null : endHostUrl.TrimEnd('/'); return string.IsNullOrEmpty(endHostUrl) ? null : endHostUrl.TrimEnd('/');
} }
@ -210,9 +222,13 @@ namespace Jellyfin.SocketSharp
if (acceptsAnything) if (acceptsAnything)
{ {
if (hasDefaultContentType) if (hasDefaultContentType)
{
return defaultContentType; return defaultContentType;
if (serverDefaultContentType != null) }
else if (serverDefaultContentType != null)
{
return serverDefaultContentType; return serverDefaultContentType;
}
} }
} }
@ -229,11 +245,16 @@ namespace Jellyfin.SocketSharp
public static bool HasAnyOfContentTypes(IRequest request, params string[] contentTypes) public static bool HasAnyOfContentTypes(IRequest request, params string[] contentTypes)
{ {
if (contentTypes == null || request.ContentType == null) return false; if (contentTypes == null || request.ContentType == null)
{
return false;
}
foreach (var contentType in contentTypes) foreach (var contentType in contentTypes)
{ {
if (IsContentType(request, contentType)) return true; if (IsContentType(request, contentType)) return true;
} }
return false; return false;
} }
@ -264,12 +285,12 @@ namespace Jellyfin.SocketSharp
} }
} }
format = LeftPart(format, '.').ToLower(); format = LeftPart(format, '.').ToLowerInvariant();
if (format.Contains("json", StringComparison.OrdinalIgnoreCase)) if (format.Contains("json", StringComparison.OrdinalIgnoreCase))
{ {
return "application/json"; return "application/json";
} }
if (format.Contains("xml", StringComparison.OrdinalIgnoreCase)) else if (format.Contains("xml", StringComparison.OrdinalIgnoreCase))
{ {
return "application/xml"; return "application/xml";
} }
@ -283,10 +304,9 @@ namespace Jellyfin.SocketSharp
{ {
return null; return null;
} }
var pos = strVal.IndexOf(needle); var pos = strVal.IndexOf(needle);
return pos == -1 return pos == -1 ? strVal : strVal.Substring(0, pos);
? strVal
: strVal.Substring(0, pos);
} }
public static string HandlerFactoryPath; public static string HandlerFactoryPath;
@ -433,6 +453,7 @@ namespace Jellyfin.SocketSharp
{ {
return null; return null;
} }
try try
{ {
return Encoding.GetEncoding(param); return Encoding.GetEncoding(param);

View File

@ -145,7 +145,7 @@ namespace MediaBrowser.Api.Images
Theme = supportsThemes ? GetThemeName(i.FullName, path) : null, Theme = supportsThemes ? GetThemeName(i.FullName, path) : null,
Context = supportsThemes ? null : GetThemeName(i.FullName, path), Context = supportsThemes ? null : GetThemeName(i.FullName, path),
Format = i.Extension.ToLower().TrimStart('.') Format = i.Extension.ToLowerInvariant().TrimStart('.')
}) })
.OrderBy(i => i.Name) .OrderBy(i => i.Name)
.ToList(); .ToList();

View File

@ -875,7 +875,9 @@ namespace MediaBrowser.Api.LiveTv
private string GetHashedString(string str) private string GetHashedString(string str)
{ {
// legacy // legacy
return BitConverter.ToString(_cryptographyProvider.ComputeSHA1(Encoding.UTF8.GetBytes(str))).Replace("-", string.Empty).ToLower(); return BitConverter.ToString(
_cryptographyProvider.ComputeSHA1(Encoding.UTF8.GetBytes(str)))
.Replace("-", string.Empty).ToLowerInvariant();
} }
public void Delete(DeleteListingProvider request) public void Delete(DeleteListingProvider request)

View File

@ -135,10 +135,10 @@ namespace MediaBrowser.Api.Playback
if (EnableOutputInSubFolder) if (EnableOutputInSubFolder)
{ {
return Path.Combine(folder, dataHash, dataHash + (outputFileExtension ?? string.Empty).ToLower()); return Path.Combine(folder, dataHash, dataHash + (outputFileExtension ?? string.Empty).ToLowerInvariant());
} }
return Path.Combine(folder, dataHash + (outputFileExtension ?? string.Empty).ToLower()); return Path.Combine(folder, dataHash + (outputFileExtension ?? string.Empty).ToLowerInvariant());
} }
protected virtual bool EnableOutputInSubFolder => false; protected virtual bool EnableOutputInSubFolder => false;

View File

@ -614,7 +614,7 @@ namespace MediaBrowser.Controller.Entities
if (!string.IsNullOrEmpty(ForcedSortName)) if (!string.IsNullOrEmpty(ForcedSortName))
{ {
// Need the ToLower because that's what CreateSortName does // Need the ToLower because that's what CreateSortName does
_sortName = ModifySortChunks(ForcedSortName).ToLower(); _sortName = ModifySortChunks(ForcedSortName).ToLowerInvariant();
} }
else else
{ {
@ -660,7 +660,7 @@ namespace MediaBrowser.Controller.Entities
return Name.TrimStart(); return Name.TrimStart();
} }
var sortable = Name.Trim().ToLower(); var sortable = Name.Trim().ToLowerInvariant();
foreach (var removeChar in ConfigurationManager.Configuration.SortRemoveCharacters) foreach (var removeChar in ConfigurationManager.Configuration.SortRemoveCharacters)
{ {

View File

@ -305,7 +305,7 @@ namespace MediaBrowser.Controller.Entities
private string GetUserDataKey(string providerId) private string GetUserDataKey(string providerId)
{ {
var key = providerId + "-" + ExtraType.ToString().ToLower(); var key = providerId + "-" + ExtraType.ToString().ToLowerInvariant();
// Make sure different trailers have their own data. // Make sure different trailers have their own data.
if (RunTimeTicks.HasValue) if (RunTimeTicks.HasValue)

View File

@ -136,7 +136,7 @@ namespace MediaBrowser.Controller.MediaEncoding
return "libtheora"; return "libtheora";
} }
return codec.ToLower(); return codec.ToLowerInvariant();
} }
return "copy"; return "copy";
@ -405,7 +405,7 @@ namespace MediaBrowser.Controller.MediaEncoding
return "libopus"; return "libopus";
} }
return codec.ToLower(); return codec.ToLowerInvariant();
} }
/// <summary> /// <summary>
@ -762,7 +762,7 @@ namespace MediaBrowser.Controller.MediaEncoding
// vaapi does not support Baseline profile, force Constrained Baseline in this case, // vaapi does not support Baseline profile, force Constrained Baseline in this case,
// which is compatible (and ugly) // which is compatible (and ugly)
if (string.Equals(videoEncoder, "h264_vaapi", StringComparison.OrdinalIgnoreCase) && if (string.Equals(videoEncoder, "h264_vaapi", StringComparison.OrdinalIgnoreCase) &&
profile != null && profile.ToLower().Contains("baseline")) profile != null && profile.ToLowerInvariant().Contains("baseline"))
{ {
profile = "constrained_baseline"; profile = "constrained_baseline";
} }
@ -2175,7 +2175,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{ {
if (string.Equals(encodingOptions.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase)) if (string.Equals(encodingOptions.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase))
{ {
switch (videoStream.Codec.ToLower()) switch (videoStream.Codec.ToLowerInvariant())
{ {
case "avc": case "avc":
case "h264": case "h264":
@ -2215,7 +2215,7 @@ namespace MediaBrowser.Controller.MediaEncoding
else if (string.Equals(encodingOptions.HardwareAccelerationType, "nvenc", StringComparison.OrdinalIgnoreCase)) else if (string.Equals(encodingOptions.HardwareAccelerationType, "nvenc", StringComparison.OrdinalIgnoreCase))
{ {
switch (videoStream.Codec.ToLower()) switch (videoStream.Codec.ToLowerInvariant())
{ {
case "avc": case "avc":
case "h264": case "h264":
@ -2254,7 +2254,7 @@ namespace MediaBrowser.Controller.MediaEncoding
else if (string.Equals(encodingOptions.HardwareAccelerationType, "mediacodec", StringComparison.OrdinalIgnoreCase)) else if (string.Equals(encodingOptions.HardwareAccelerationType, "mediacodec", StringComparison.OrdinalIgnoreCase))
{ {
switch (videoStream.Codec.ToLower()) switch (videoStream.Codec.ToLowerInvariant())
{ {
case "avc": case "avc":
case "h264": case "h264":
@ -2299,7 +2299,7 @@ namespace MediaBrowser.Controller.MediaEncoding
else if (string.Equals(encodingOptions.HardwareAccelerationType, "omx", StringComparison.OrdinalIgnoreCase)) else if (string.Equals(encodingOptions.HardwareAccelerationType, "omx", StringComparison.OrdinalIgnoreCase))
{ {
switch (videoStream.Codec.ToLower()) switch (videoStream.Codec.ToLowerInvariant())
{ {
case "avc": case "avc":
case "h264": case "h264":
@ -2324,7 +2324,7 @@ namespace MediaBrowser.Controller.MediaEncoding
return "-hwaccel dxva2"; return "-hwaccel dxva2";
} }
switch (videoStream.Codec.ToLower()) switch (videoStream.Codec.ToLowerInvariant())
{ {
case "avc": case "avc":
case "h264": case "h264":

View File

@ -417,7 +417,7 @@ namespace MediaBrowser.LocalMetadata.Images
var seriesFiles = GetFiles(series, false, directoryService).ToList(); var seriesFiles = GetFiles(series, false, directoryService).ToList();
// Try using the season name // Try using the season name
var prefix = season.Name.ToLower().Replace(" ", string.Empty); var prefix = season.Name.ToLowerInvariant().Replace(" ", string.Empty);
var filenamePrefixes = new List<string> { prefix }; var filenamePrefixes = new List<string> { prefix };

View File

@ -172,7 +172,7 @@ namespace MediaBrowser.LocalMetadata.Savers
writer.WriteElementString("Added", item.DateCreated.ToLocalTime().ToString("G")); writer.WriteElementString("Added", item.DateCreated.ToLocalTime().ToString("G"));
writer.WriteElementString("LockData", item.IsLocked.ToString().ToLower()); writer.WriteElementString("LockData", item.IsLocked.ToString(CultureInfo.InvariantCulture).ToLowerInvariant());
if (item.LockedFields.Length > 0) if (item.LockedFields.Length > 0)
{ {
@ -410,7 +410,9 @@ namespace MediaBrowser.LocalMetadata.Savers
writer.WriteStartElement("Share"); writer.WriteStartElement("Share");
writer.WriteElementString("UserId", share.UserId); writer.WriteElementString("UserId", share.UserId);
writer.WriteElementString("CanEdit", share.CanEdit.ToString().ToLower()); writer.WriteElementString(
"CanEdit",
share.CanEdit.ToString(CultureInfo.InvariantCulture).ToLowerInvariant());
writer.WriteEndElement(); writer.WriteEndElement();
} }

View File

@ -272,7 +272,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
var outputFileExtension = GetOutputFileExtension(state); var outputFileExtension = GetOutputFileExtension(state);
var filename = state.Id + (outputFileExtension ?? string.Empty).ToLower(); var filename = state.Id + (outputFileExtension ?? string.Empty).ToLowerInvariant();
return Path.Combine(folder, filename); return Path.Combine(folder, filename);
} }
@ -310,7 +310,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
{ {
if (string.Equals(GetEncodingOptions().HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase)) if (string.Equals(GetEncodingOptions().HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase))
{ {
switch (state.MediaSource.VideoStream.Codec.ToLower()) switch (state.MediaSource.VideoStream.Codec.ToLowerInvariant())
{ {
case "avc": case "avc":
case "h264": case "h264":

View File

@ -44,7 +44,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
if (!eventsStarted) if (!eventsStarted)
header.AppendLine(line); header.AppendLine(line);
if (line.Trim().ToLower() == "[events]") if (line.Trim().ToLowerInvariant() == "[events]")
{ {
eventsStarted = true; eventsStarted = true;
} }
@ -54,25 +54,25 @@ namespace MediaBrowser.MediaEncoding.Subtitles
} }
else if (eventsStarted && line.Trim().Length > 0) else if (eventsStarted && line.Trim().Length > 0)
{ {
string s = line.Trim().ToLower(); string s = line.Trim().ToLowerInvariant();
if (s.StartsWith("format:")) if (s.StartsWith("format:"))
{ {
if (line.Length > 10) if (line.Length > 10)
{ {
format = line.ToLower().Substring(8).Split(','); format = line.ToLowerInvariant().Substring(8).Split(',');
for (int i = 0; i < format.Length; i++) for (int i = 0; i < format.Length; i++)
{ {
if (format[i].Trim().ToLower() == "layer") if (format[i].Trim().ToLowerInvariant() == "layer")
indexLayer = i; indexLayer = i;
else if (format[i].Trim().ToLower() == "start") else if (format[i].Trim().ToLowerInvariant() == "start")
indexStart = i; indexStart = i;
else if (format[i].Trim().ToLower() == "end") else if (format[i].Trim().ToLowerInvariant() == "end")
indexEnd = i; indexEnd = i;
else if (format[i].Trim().ToLower() == "text") else if (format[i].Trim().ToLowerInvariant() == "text")
indexText = i; indexText = i;
else if (format[i].Trim().ToLower() == "effect") else if (format[i].Trim().ToLowerInvariant() == "effect")
indexEffect = i; indexEffect = i;
else if (format[i].Trim().ToLower() == "style") else if (format[i].Trim().ToLowerInvariant() == "style")
indexStyle = i; indexStyle = i;
} }
} }
@ -222,7 +222,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
// switch to rrggbb from bbggrr // switch to rrggbb from bbggrr
color = "#" + color.Remove(color.Length - 6) + color.Substring(color.Length - 2, 2) + color.Substring(color.Length - 4, 2) + color.Substring(color.Length - 6, 2); color = "#" + color.Remove(color.Length - 6) + color.Substring(color.Length - 2, 2) + color.Substring(color.Length - 4, 2) + color.Substring(color.Length - 6, 2);
color = color.ToLower(); color = color.ToLowerInvariant();
text = text.Remove(start, end - start + 1); text = text.Remove(start, end - start + 1);
if (italic) if (italic)
@ -252,7 +252,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
// switch to rrggbb from bbggrr // switch to rrggbb from bbggrr
color = "#" + color.Remove(color.Length - 6) + color.Substring(color.Length - 2, 2) + color.Substring(color.Length - 4, 2) + color.Substring(color.Length - 6, 2); color = "#" + color.Remove(color.Length - 6) + color.Substring(color.Length - 2, 2) + color.Substring(color.Length - 4, 2) + color.Substring(color.Length - 6, 2);
color = color.ToLower(); color = color.ToLowerInvariant();
text = text.Remove(start, end - start + 1); text = text.Remove(start, end - start + 1);
if (italic) if (italic)
@ -367,7 +367,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
color = color.PadLeft(6, '0'); color = color.PadLeft(6, '0');
// switch to rrggbb from bbggrr // switch to rrggbb from bbggrr
color = "#" + color.Remove(color.Length - 6) + color.Substring(color.Length - 2, 2) + color.Substring(color.Length - 4, 2) + color.Substring(color.Length - 6, 2); color = "#" + color.Remove(color.Length - 6) + color.Substring(color.Length - 2, 2) + color.Substring(color.Length - 4, 2) + color.Substring(color.Length - 6, 2);
color = color.ToLower(); color = color.ToLowerInvariant();
extraTags += " color=\"" + color + "\""; extraTags += " color=\"" + color + "\"";
} }

View File

@ -223,7 +223,7 @@ namespace MediaBrowser.Model.Dlna
list.Add(new NameValuePair("DeviceProfileId", item.DeviceProfileId ?? string.Empty)); list.Add(new NameValuePair("DeviceProfileId", item.DeviceProfileId ?? string.Empty));
list.Add(new NameValuePair("DeviceId", item.DeviceId ?? string.Empty)); list.Add(new NameValuePair("DeviceId", item.DeviceId ?? string.Empty));
list.Add(new NameValuePair("MediaSourceId", item.MediaSourceId ?? string.Empty)); list.Add(new NameValuePair("MediaSourceId", item.MediaSourceId ?? string.Empty));
list.Add(new NameValuePair("Static", item.IsDirectStream.ToString().ToLower())); list.Add(new NameValuePair("Static", item.IsDirectStream.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()));
list.Add(new NameValuePair("VideoCodec", videoCodecs)); list.Add(new NameValuePair("VideoCodec", videoCodecs));
list.Add(new NameValuePair("AudioCodec", audioCodecs)); list.Add(new NameValuePair("AudioCodec", audioCodecs));
list.Add(new NameValuePair("AudioStreamIndex", item.AudioStreamIndex.HasValue ? item.AudioStreamIndex.Value.ToString(CultureInfo.InvariantCulture) : string.Empty)); list.Add(new NameValuePair("AudioStreamIndex", item.AudioStreamIndex.HasValue ? item.AudioStreamIndex.Value.ToString(CultureInfo.InvariantCulture) : string.Empty));
@ -251,7 +251,7 @@ namespace MediaBrowser.Model.Dlna
list.Add(new NameValuePair("PlaySessionId", item.PlaySessionId ?? string.Empty)); list.Add(new NameValuePair("PlaySessionId", item.PlaySessionId ?? string.Empty));
list.Add(new NameValuePair("api_key", accessToken ?? string.Empty)); list.Add(new NameValuePair("api_key", accessToken ?? string.Empty));
string liveStreamId = item.MediaSource == null ? null : item.MediaSource.LiveStreamId; string liveStreamId = item.MediaSource?.LiveStreamId;
list.Add(new NameValuePair("LiveStreamId", liveStreamId ?? string.Empty)); list.Add(new NameValuePair("LiveStreamId", liveStreamId ?? string.Empty));
list.Add(new NameValuePair("SubtitleMethod", item.SubtitleStreamIndex.HasValue && item.SubtitleDeliveryMethod != SubtitleDeliveryMethod.External ? item.SubtitleDeliveryMethod.ToString() : string.Empty)); list.Add(new NameValuePair("SubtitleMethod", item.SubtitleStreamIndex.HasValue && item.SubtitleDeliveryMethod != SubtitleDeliveryMethod.External ? item.SubtitleDeliveryMethod.ToString() : string.Empty));
@ -261,37 +261,37 @@ namespace MediaBrowser.Model.Dlna
{ {
if (item.RequireNonAnamorphic) if (item.RequireNonAnamorphic)
{ {
list.Add(new NameValuePair("RequireNonAnamorphic", item.RequireNonAnamorphic.ToString().ToLower())); list.Add(new NameValuePair("RequireNonAnamorphic", item.RequireNonAnamorphic.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()));
} }
list.Add(new NameValuePair("TranscodingMaxAudioChannels", item.TranscodingMaxAudioChannels.HasValue ? item.TranscodingMaxAudioChannels.Value.ToString(CultureInfo.InvariantCulture) : string.Empty)); list.Add(new NameValuePair("TranscodingMaxAudioChannels", item.TranscodingMaxAudioChannels.HasValue ? item.TranscodingMaxAudioChannels.Value.ToString(CultureInfo.InvariantCulture) : string.Empty));
if (item.EnableSubtitlesInManifest) if (item.EnableSubtitlesInManifest)
{ {
list.Add(new NameValuePair("EnableSubtitlesInManifest", item.EnableSubtitlesInManifest.ToString().ToLower())); list.Add(new NameValuePair("EnableSubtitlesInManifest", item.EnableSubtitlesInManifest.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()));
} }
if (item.EnableMpegtsM2TsMode) if (item.EnableMpegtsM2TsMode)
{ {
list.Add(new NameValuePair("EnableMpegtsM2TsMode", item.EnableMpegtsM2TsMode.ToString().ToLower())); list.Add(new NameValuePair("EnableMpegtsM2TsMode", item.EnableMpegtsM2TsMode.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()));
} }
if (item.EstimateContentLength) if (item.EstimateContentLength)
{ {
list.Add(new NameValuePair("EstimateContentLength", item.EstimateContentLength.ToString().ToLower())); list.Add(new NameValuePair("EstimateContentLength", item.EstimateContentLength.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()));
} }
if (item.TranscodeSeekInfo != TranscodeSeekInfo.Auto) if (item.TranscodeSeekInfo != TranscodeSeekInfo.Auto)
{ {
list.Add(new NameValuePair("TranscodeSeekInfo", item.TranscodeSeekInfo.ToString().ToLower())); list.Add(new NameValuePair("TranscodeSeekInfo", item.TranscodeSeekInfo.ToString().ToLowerInvariant()));
} }
if (item.CopyTimestamps) if (item.CopyTimestamps)
{ {
list.Add(new NameValuePair("CopyTimestamps", item.CopyTimestamps.ToString().ToLower())); list.Add(new NameValuePair("CopyTimestamps", item.CopyTimestamps.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()));
} }
list.Add(new NameValuePair("RequireAvc", item.RequireAvc.ToString().ToLower())); list.Add(new NameValuePair("RequireAvc", item.RequireAvc.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()));
} }
list.Add(new NameValuePair("Tag", item.MediaSource.ETag ?? string.Empty)); list.Add(new NameValuePair("Tag", item.MediaSource.ETag ?? string.Empty));
@ -316,7 +316,7 @@ namespace MediaBrowser.Model.Dlna
list.Add(new NameValuePair("MinSegments", item.MinSegments.Value.ToString(CultureInfo.InvariantCulture))); list.Add(new NameValuePair("MinSegments", item.MinSegments.Value.ToString(CultureInfo.InvariantCulture)));
} }
list.Add(new NameValuePair("BreakOnNonKeyFrames", item.BreakOnNonKeyFrames.ToString())); list.Add(new NameValuePair("BreakOnNonKeyFrames", item.BreakOnNonKeyFrames.ToString(CultureInfo.InvariantCulture)));
} }
foreach (var pair in item.StreamOptions) foreach (var pair in item.StreamOptions)
@ -332,7 +332,7 @@ namespace MediaBrowser.Model.Dlna
if (!item.IsDirectStream) if (!item.IsDirectStream)
{ {
list.Add(new NameValuePair("TranscodeReasons", string.Join(",", item.TranscodeReasons.Distinct().Select(i => i.ToString()).ToArray()))); list.Add(new NameValuePair("TranscodeReasons", string.Join(",", item.TranscodeReasons.Distinct().Select(i => i.ToString()))));
} }
return list; return list;

View File

@ -104,7 +104,7 @@ namespace MediaBrowser.Model.Entities
attributes.Add("Default"); attributes.Add("Default");
} }
return string.Join(" ", attributes.ToArray()); return string.Join(" ", attributes);
} }
if (Type == MediaStreamType.Video) if (Type == MediaStreamType.Video)
@ -120,10 +120,10 @@ namespace MediaBrowser.Model.Entities
if (!string.IsNullOrEmpty(Codec)) if (!string.IsNullOrEmpty(Codec))
{ {
attributes.Add(Codec.ToUpper()); attributes.Add(Codec.ToUpperInvariant());
} }
return string.Join(" ", attributes.ToArray()); return string.Join(" ", attributes);
} }
if (Type == MediaStreamType.Subtitle) if (Type == MediaStreamType.Subtitle)

View File

@ -51,7 +51,7 @@ namespace MediaBrowser.Model.Extensions
public static string FirstToUpper(this string str) public static string FirstToUpper(this string str)
{ {
return string.IsNullOrEmpty(str) ? "" : str.Substring(0, 1).ToUpper() + str.Substring(1); return string.IsNullOrEmpty(str) ? string.Empty : str.Substring(0, 1).ToUpperInvariant() + str.Substring(1);
} }
} }
} }

View File

@ -8,9 +8,12 @@ namespace MediaBrowser.Model.MediaInfo
public static string GetFriendlyName(string codec) public static string GetFriendlyName(string codec)
{ {
if (string.IsNullOrEmpty(codec)) return ""; if (string.IsNullOrEmpty(codec))
{
return string.Empty;
}
switch (codec.ToLower()) switch (codec.ToLowerInvariant())
{ {
case "ac3": case "ac3":
return "Dolby Digital"; return "Dolby Digital";
@ -19,7 +22,7 @@ namespace MediaBrowser.Model.MediaInfo
case "dca": case "dca":
return "DTS"; return "DTS";
default: default:
return codec.ToUpper(); return codec.ToUpperInvariant();
} }
} }
} }

View File

@ -158,7 +158,7 @@ namespace MediaBrowser.Model.Net
// Catch-all for all video types that don't require specific mime types // Catch-all for all video types that don't require specific mime types
if (VideoFileExtensionsDictionary.ContainsKey(ext)) if (VideoFileExtensionsDictionary.ContainsKey(ext))
{ {
return "video/" + ext.TrimStart('.').ToLower(); return "video/" + ext.TrimStart('.').ToLowerInvariant();
} }
// Type text // Type text

View File

@ -420,7 +420,7 @@ namespace MediaBrowser.Providers.Manager
filename = GetBackdropSaveFilename(item.GetImages(type), "screenshot", "screenshot", imageIndex); filename = GetBackdropSaveFilename(item.GetImages(type), "screenshot", "screenshot", imageIndex);
break; break;
default: default:
filename = type.ToString().ToLower(); filename = type.ToString().ToLowerInvariant();
break; break;
} }
@ -429,7 +429,7 @@ namespace MediaBrowser.Providers.Manager
extension = ".jpg"; extension = ".jpg";
} }
extension = extension.ToLower(); extension = extension.ToLowerInvariant();
string path = null; string path = null;

View File

@ -148,7 +148,7 @@ namespace MediaBrowser.Providers.Manager
} }
else else
{ {
var mimeType = "image/" + response.Format.ToString().ToLower(); var mimeType = "image/" + response.Format.ToString().ToLowerInvariant();
await _providerManager.SaveImage(item, response.Stream, mimeType, imageType, null, cancellationToken).ConfigureAwait(false); await _providerManager.SaveImage(item, response.Stream, mimeType, imageType, null, cancellationToken).ConfigureAwait(false);
} }

View File

@ -119,7 +119,7 @@ namespace MediaBrowser.Providers.MediaInfo
continue; continue;
} }
var codec = Path.GetExtension(fullName).ToLower().TrimStart('.'); var codec = Path.GetExtension(fullName).ToLowerInvariant().TrimStart('.');
if (string.Equals(codec, "txt", StringComparison.OrdinalIgnoreCase)) if (string.Equals(codec, "txt", StringComparison.OrdinalIgnoreCase))
{ {

View File

@ -285,7 +285,7 @@ namespace MediaBrowser.Providers.Movies
if (parts.Length == 2) if (parts.Length == 2)
{ {
language = parts[0] + "-" + parts[1].ToUpper(); language = parts[0] + "-" + parts[1].ToUpperInvariant();
} }
} }

View File

@ -72,7 +72,7 @@ namespace MediaBrowser.Providers.Movies
} }
_logger.LogInformation("MovieDbProvider: Finding id for item: " + name); _logger.LogInformation("MovieDbProvider: Finding id for item: " + name);
var language = idInfo.MetadataLanguage.ToLower(); var language = idInfo.MetadataLanguage.ToLowerInvariant();
//nope - search for it //nope - search for it
//var searchType = item is BoxSet ? "collection" : "movie"; //var searchType = item is BoxSet ? "collection" : "movie";

View File

@ -168,14 +168,14 @@ namespace MediaBrowser.Providers.Subtitles
memoryStream.Position = 0; memoryStream.Position = 0;
var savePaths = new List<string>(); var savePaths = new List<string>();
var saveFileName = _fileSystem.GetFileNameWithoutExtension(video.Path) + "." + response.Language.ToLower(); var saveFileName = _fileSystem.GetFileNameWithoutExtension(video.Path) + "." + response.Language.ToLowerInvariant();
if (response.IsForced) if (response.IsForced)
{ {
saveFileName += ".forced"; saveFileName += ".forced";
} }
saveFileName += "." + response.Format.ToLower(); saveFileName += "." + response.Format.ToLowerInvariant();
if (saveInMediaFolder) if (saveInMediaFolder)
{ {
@ -305,7 +305,7 @@ namespace MediaBrowser.Providers.Subtitles
private string GetProviderId(string name) private string GetProviderId(string name)
{ {
return name.ToLower().GetMD5().ToString("N"); return name.ToLowerInvariant().GetMD5().ToString("N");
} }
private ISubtitleProvider GetProvider(string id) private ISubtitleProvider GetProvider(string id)

View File

@ -66,7 +66,7 @@ namespace MediaBrowser.Providers.TV
} }
// pt-br is just pt to tvdb // pt-br is just pt to tvdb
return language.Split('-')[0].ToLower(); return language.Split('-')[0].ToLowerInvariant();
} }
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(SeriesInfo searchInfo, CancellationToken cancellationToken) public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(SeriesInfo searchInfo, CancellationToken cancellationToken)
@ -776,7 +776,7 @@ namespace MediaBrowser.Providers.TV
/// <returns>System.String.</returns> /// <returns>System.String.</returns>
private string GetComparableName(string name) private string GetComparableName(string name)
{ {
name = name.ToLower(); name = name.ToLowerInvariant();
name = _localizationManager.NormalizeFormKD(name); name = _localizationManager.NormalizeFormKD(name);
var sb = new StringBuilder(); var sb = new StringBuilder();
foreach (var c in name) foreach (var c in name)
@ -1620,7 +1620,7 @@ namespace MediaBrowser.Providers.TV
{ {
var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds); var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds);
var seriesXmlFilename = language.ToLower() + ".xml"; var seriesXmlFilename = language.ToLowerInvariant() + ".xml";
return Path.Combine(seriesDataPath, seriesXmlFilename); return Path.Combine(seriesDataPath, seriesXmlFilename);
} }

View File

@ -290,7 +290,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
foreach (var stream in mediaStreams) foreach (var stream in mediaStreams)
{ {
writer.WriteStartElement(stream.Type.ToString().ToLower()); writer.WriteStartElement(stream.Type.ToString().ToLowerInvariant());
if (!string.IsNullOrEmpty(stream.Codec)) if (!string.IsNullOrEmpty(stream.Codec))
{ {
@ -471,7 +471,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
writer.WriteElementString("customrating", item.CustomRating); writer.WriteElementString("customrating", item.CustomRating);
} }
writer.WriteElementString("lockdata", item.IsLocked.ToString().ToLower()); writer.WriteElementString("lockdata", item.IsLocked.ToString(CultureInfo.InvariantCulture).ToLowerInvariant());
if (item.LockedFields.Length > 0) if (item.LockedFields.Length > 0)
{ {
@ -871,21 +871,21 @@ namespace MediaBrowser.XbmcMetadata.Savers
var userdata = userDataRepo.GetUserData(user, item); var userdata = userDataRepo.GetUserData(user, item);
writer.WriteElementString("isuserfavorite", userdata.IsFavorite.ToString().ToLower()); writer.WriteElementString("isuserfavorite", userdata.IsFavorite.ToString(CultureInfo.InvariantCulture).ToLowerInvariant());
if (userdata.Rating.HasValue) if (userdata.Rating.HasValue)
{ {
writer.WriteElementString("userrating", userdata.Rating.Value.ToString(CultureInfo.InvariantCulture).ToLower()); writer.WriteElementString("userrating", userdata.Rating.Value.ToString(CultureInfo.InvariantCulture).ToLowerInvariant());
} }
if (!item.IsFolder) if (!item.IsFolder)
{ {
writer.WriteElementString("playcount", userdata.PlayCount.ToString(UsCulture)); writer.WriteElementString("playcount", userdata.PlayCount.ToString(UsCulture));
writer.WriteElementString("watched", userdata.Played.ToString().ToLower()); writer.WriteElementString("watched", userdata.Played.ToString(CultureInfo.InvariantCulture).ToLowerInvariant());
if (userdata.LastPlayedDate.HasValue) if (userdata.LastPlayedDate.HasValue)
{ {
writer.WriteElementString("lastplayed", userdata.LastPlayedDate.Value.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss").ToLower()); writer.WriteElementString("lastplayed", userdata.LastPlayedDate.Value.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss").ToLowerInvariant());
} }
writer.WriteStartElement("resume"); writer.WriteStartElement("resume");
@ -901,12 +901,13 @@ namespace MediaBrowser.XbmcMetadata.Savers
private void AddActors(List<PersonInfo> people, XmlWriter writer, ILibraryManager libraryManager, IFileSystem fileSystem, IServerConfigurationManager config, bool saveImagePath) private void AddActors(List<PersonInfo> people, XmlWriter writer, ILibraryManager libraryManager, IFileSystem fileSystem, IServerConfigurationManager config, bool saveImagePath)
{ {
var actors = people foreach (var person in people)
.Where(i => !IsPersonType(i, PersonType.Director) && !IsPersonType(i, PersonType.Writer))
.ToList();
foreach (var person in actors)
{ {
if (IsPersonType(person, PersonType.Director) || IsPersonType(person, PersonType.Writer))
{
continue;
}
writer.WriteStartElement("actor"); writer.WriteStartElement("actor");
if (!string.IsNullOrWhiteSpace(person.Name)) if (!string.IsNullOrWhiteSpace(person.Name))
@ -1021,7 +1022,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
private string GetTagForProviderKey(string providerKey) private string GetTagForProviderKey(string providerKey)
{ {
return providerKey.ToLower() + "id"; return providerKey.ToLowerInvariant() + "id";
} }
} }
} }

View File

@ -486,7 +486,7 @@ namespace SocketHttpListener
if (method == CompressionMethod.None) if (method == CompressionMethod.None)
return string.Empty; return string.Empty;
var m = string.Format("permessage-{0}", method.ToString().ToLower()); var m = string.Format("permessage-{0}", method.ToString().ToLowerInvariant());
if (parameters == null || parameters.Length == 0) if (parameters == null || parameters.Length == 0)
return m; return m;

View File

@ -155,7 +155,7 @@ namespace SocketHttpListener.Net
} }
else else
{ {
header = header.ToLower(CultureInfo.InvariantCulture); header = header.ToLowerInvariant();
_keepAlive = _keepAlive =
header.IndexOf("close", StringComparison.OrdinalIgnoreCase) < 0 || header.IndexOf("close", StringComparison.OrdinalIgnoreCase) < 0 ||
header.IndexOf("keep-alive", StringComparison.OrdinalIgnoreCase) >= 0; header.IndexOf("keep-alive", StringComparison.OrdinalIgnoreCase) >= 0;