Remove the need for NullLogger

This commit is contained in:
Bond_009
2018-12-14 20:17:29 +01:00
parent 3d3ec3588b
commit b7ebb67cbb
28 changed files with 62 additions and 93 deletions

View File

@@ -99,7 +99,7 @@ namespace Emby.Server.Implementations.Services
pathsAtFirstMatch.Add(restPath);
}
public RestPath GetRestPathForRequest(string httpMethod, string pathInfo, ILogger logger)
public RestPath GetRestPathForRequest(string httpMethod, string pathInfo)
{
var matchUsingPathParts = RestPath.GetPathPartsForMatching(pathInfo);
@@ -117,7 +117,7 @@ namespace Emby.Server.Implementations.Services
RestPath bestMatch = null;
foreach (var restPath in firstMatches)
{
var score = restPath.MatchScore(httpMethod, matchUsingPathParts, logger);
var score = restPath.MatchScore(httpMethod, matchUsingPathParts);
if (score > bestScore)
{
bestScore = score;
@@ -140,7 +140,7 @@ namespace Emby.Server.Implementations.Services
RestPath bestMatch = null;
foreach (var restPath in firstMatches)
{
var score = restPath.MatchScore(httpMethod, matchUsingPathParts, logger);
var score = restPath.MatchScore(httpMethod, matchUsingPathParts);
if (score > bestScore)
{
bestScore = score;

View File

@@ -24,11 +24,11 @@ namespace Emby.Server.Implementations.Services
return Task.FromResult(host.CreateInstance(requestType));
}
public static RestPath FindMatchingRestPath(string httpMethod, string pathInfo, ILogger logger, out string contentType)
public static RestPath FindMatchingRestPath(string httpMethod, string pathInfo, out string contentType)
{
pathInfo = GetSanitizedPathInfo(pathInfo, out contentType);
return ServiceController.Instance.GetRestPathForRequest(httpMethod, pathInfo, logger);
return ServiceController.Instance.GetRestPathForRequest(httpMethod, pathInfo);
}
public static string GetSanitizedPathInfo(string pathInfo, out string contentType)
@@ -63,8 +63,7 @@ namespace Emby.Server.Implementations.Services
if (this.RestPath == null)
{
string contentType;
// TODO: @bond NullLogger
this.RestPath = FindMatchingRestPath(httpMethod, pathInfo, null, out contentType);
this.RestPath = FindMatchingRestPath(httpMethod, pathInfo, out contentType);
if (contentType != null)
ResponseContentType = contentType;

View File

@@ -309,10 +309,10 @@ namespace Emby.Server.Implementations.Services
private readonly Dictionary<string, string> propertyNamesMap = new Dictionary<string, string>();
public int MatchScore(string httpMethod, string[] withPathInfoParts, ILogger logger)
public int MatchScore(string httpMethod, string[] withPathInfoParts)
{
int wildcardMatchCount;
var isMatch = IsMatch(httpMethod, withPathInfoParts, logger, out wildcardMatchCount);
var isMatch = IsMatch(httpMethod, withPathInfoParts, out wildcardMatchCount);
if (!isMatch)
{
return -1;
@@ -348,31 +348,27 @@ namespace Emby.Server.Implementations.Services
/// For performance withPathInfoParts should already be a lower case string
/// to minimize redundant matching operations.
/// </summary>
public bool IsMatch(string httpMethod, string[] withPathInfoParts, ILogger logger, out int wildcardMatchCount)
public bool IsMatch(string httpMethod, string[] withPathInfoParts, out int wildcardMatchCount)
{
wildcardMatchCount = 0;
if (withPathInfoParts.Length != this.PathComponentsCount && !this.IsWildCardPath)
{
//logger.LogInformation("withPathInfoParts mismatch for {0} for {1}", httpMethod, string.Join("/", withPathInfoParts));
return false;
return false;
}
if (!Verbs.Contains(httpMethod, StringComparer.OrdinalIgnoreCase))
{
//logger.LogInformation("allowsAllVerbs mismatch for {0} for {1} allowedverbs {2}", httpMethod, string.Join("/", withPathInfoParts), this.allowedVerbs);
return false;
}
if (!ExplodeComponents(ref withPathInfoParts))
{
//logger.LogInformation("ExplodeComponents mismatch for {0} for {1}", httpMethod, string.Join("/", withPathInfoParts));
return false;
}
if (this.TotalComponentsCount != withPathInfoParts.Length && !this.IsWildCardPath)
{
//logger.LogInformation("TotalComponentsCount mismatch for {0} for {1}", httpMethod, string.Join("/", withPathInfoParts));
return false;
}
@@ -393,7 +389,6 @@ namespace Emby.Server.Implementations.Services
// Ensure there are still enough parts left to match the remainder
if ((withPathInfoParts.Length - pathIx) < (this.TotalComponentsCount - i - 1))
{
//logger.LogInformation("withPathInfoParts length mismatch for {0} for {1}", httpMethod, string.Join("/", withPathInfoParts));
return false;
}
}
@@ -416,7 +411,6 @@ namespace Emby.Server.Implementations.Services
if (withPathInfoParts.Length <= pathIx || !LiteralsEqual(withPathInfoParts[pathIx], literalToMatch))
{
//logger.LogInformation("withPathInfoParts2 length mismatch for {0} for {1}. not equals: {2} != {3}.", httpMethod, string.Join("/", withPathInfoParts), withPathInfoParts[pathIx], literalToMatch);
return false;
}
pathIx++;