mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-03 06:18:28 +01:00
Merge branch 'dev' into cleanup
This commit is contained in:
@@ -29,8 +29,8 @@ namespace Emby.Server.Implementations.Services
|
||||
|
||||
public HttpStatusCode StatusCode
|
||||
{
|
||||
get { return (HttpStatusCode)Status; }
|
||||
set { Status = (int)value; }
|
||||
get => (HttpStatusCode)Status;
|
||||
set => Status = (int)value;
|
||||
}
|
||||
|
||||
public IRequest RequestContext { get; set; }
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Emby.Server.Implementations.Services
|
||||
return deserializer(requestType, httpReq.InputStream);
|
||||
}
|
||||
}
|
||||
return Task.FromResult(host.CreateInstance(requestType));
|
||||
return Task.FromResult(host.CreateInstance(requestType));
|
||||
}
|
||||
|
||||
public static RestPath FindMatchingRestPath(string httpMethod, string pathInfo, out string contentType)
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Emby.Server.Implementations.Services
|
||||
public int PathComponentsCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The total number of segments after subparts have been exploded ('.')
|
||||
/// The total number of segments after subparts have been exploded ('.')
|
||||
/// e.g. /path/to/here.ext == 4
|
||||
/// </summary>
|
||||
public int TotalComponentsCount { get; set; }
|
||||
@@ -50,7 +50,7 @@ namespace Emby.Server.Implementations.Services
|
||||
|
||||
public Type ServiceType { get; private set; }
|
||||
|
||||
public string Path { get { return this.restPath; } }
|
||||
public string Path => this.restPath;
|
||||
|
||||
public string Summary { get; private set; }
|
||||
public string Description { get; private set; }
|
||||
@@ -58,10 +58,7 @@ namespace Emby.Server.Implementations.Services
|
||||
|
||||
public int Priority { get; set; } //passed back to RouteAttribute
|
||||
|
||||
public IEnumerable<string> PathVariables
|
||||
{
|
||||
get { return this.variablesNames.Where(e => !string.IsNullOrWhiteSpace(e)); }
|
||||
}
|
||||
public IEnumerable<string> PathVariables => this.variablesNames.Where(e => !string.IsNullOrWhiteSpace(e));
|
||||
|
||||
public static string[] GetPathPartsForMatching(string pathInfo)
|
||||
{
|
||||
@@ -117,7 +114,7 @@ namespace Emby.Server.Implementations.Services
|
||||
var hasSeparators = new List<bool>();
|
||||
foreach (var component in this.restPath.Split(PathSeperatorChar))
|
||||
{
|
||||
if (String.IsNullOrEmpty(component)) continue;
|
||||
if (string.IsNullOrEmpty(component)) continue;
|
||||
|
||||
if (StringContains(component, VariablePrefix)
|
||||
&& component.IndexOf(ComponentSeperator) != -1)
|
||||
@@ -354,7 +351,7 @@ namespace Emby.Server.Implementations.Services
|
||||
|
||||
if (withPathInfoParts.Length != this.PathComponentsCount && !this.IsWildCardPath)
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Verbs.Contains(httpMethod, StringComparer.OrdinalIgnoreCase))
|
||||
@@ -420,10 +417,10 @@ namespace Emby.Server.Implementations.Services
|
||||
return pathIx == withPathInfoParts.Length;
|
||||
}
|
||||
|
||||
private bool LiteralsEqual(string str1, string str2)
|
||||
private static bool LiteralsEqual(string str1, string str2)
|
||||
{
|
||||
// Most cases
|
||||
if (String.Equals(str1, str2, StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(str1, str2, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -433,7 +430,7 @@ namespace Emby.Server.Implementations.Services
|
||||
str2 = str2.ToUpperInvariant();
|
||||
|
||||
// Invariant IgnoreCase would probably be better but it's not available in PCL
|
||||
return String.Equals(str1, str2, StringComparison.CurrentCultureIgnoreCase);
|
||||
return string.Equals(str1, str2, StringComparison.CurrentCultureIgnoreCase);
|
||||
}
|
||||
|
||||
private bool ExplodeComponents(ref string[] withPathInfoParts)
|
||||
@@ -442,7 +439,7 @@ namespace Emby.Server.Implementations.Services
|
||||
for (var i = 0; i < withPathInfoParts.Length; i++)
|
||||
{
|
||||
var component = withPathInfoParts[i];
|
||||
if (String.IsNullOrEmpty(component)) continue;
|
||||
if (string.IsNullOrEmpty(component)) continue;
|
||||
|
||||
if (this.PathComponentsCount != this.TotalComponentsCount
|
||||
&& this.componentsWithSeparators[i])
|
||||
@@ -473,7 +470,7 @@ namespace Emby.Server.Implementations.Services
|
||||
&& requestComponents.Length >= this.TotalComponentsCount - this.wildcardCount;
|
||||
|
||||
if (!isValidWildCardPath)
|
||||
throw new ArgumentException(String.Format(
|
||||
throw new ArgumentException(string.Format(
|
||||
"Path Mismatch: Request Path '{0}' has invalid number of components compared to: '{1}'",
|
||||
pathInfo, this.restPath));
|
||||
}
|
||||
@@ -492,7 +489,7 @@ namespace Emby.Server.Implementations.Services
|
||||
string propertyNameOnRequest;
|
||||
if (!this.propertyNamesMap.TryGetValue(variableName.ToLower(), out propertyNameOnRequest))
|
||||
{
|
||||
if (String.Equals("ignore", variableName, StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals("ignore", variableName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
pathIx++;
|
||||
continue;
|
||||
@@ -522,12 +519,12 @@ namespace Emby.Server.Implementations.Services
|
||||
// hits a match for the next element in the definition (which must be a literal)
|
||||
// It may consume 0 or more path parts
|
||||
var stopLiteral = i == this.TotalComponentsCount - 1 ? null : this.literalsToMatch[i + 1];
|
||||
if (!String.Equals(requestComponents[pathIx], stopLiteral, StringComparison.OrdinalIgnoreCase))
|
||||
if (!string.Equals(requestComponents[pathIx], stopLiteral, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append(value);
|
||||
pathIx++;
|
||||
while (!String.Equals(requestComponents[pathIx], stopLiteral, StringComparison.OrdinalIgnoreCase))
|
||||
while (!string.Equals(requestComponents[pathIx], stopLiteral, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
sb.Append(PathSeperatorChar + requestComponents[pathIx++]);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Emby.Server.Implementations.Services
|
||||
/// <summary>
|
||||
/// Donated by Ivan Korneliuk from his post:
|
||||
/// http://korneliuk.blogspot.com/2012/08/servicestack-reusing-dtos.html
|
||||
///
|
||||
///
|
||||
/// Modified to only allow using routes matching the supplied HTTP Verb
|
||||
/// </summary>
|
||||
public static class UrlExtensions
|
||||
|
||||
Reference in New Issue
Block a user