diff options
| author | stefan <stefan@hegedues.at> | 2018-09-12 19:26:21 +0200 |
|---|---|---|
| committer | stefan <stefan@hegedues.at> | 2018-09-12 19:26:21 +0200 |
| commit | 48facb797ed912e4ea6b04b17d1ff190ac2daac4 (patch) | |
| tree | 8dae77a31670a888d733484cb17dd4077d5444e8 /Emby.Server.Implementations/Services/ServiceController.cs | |
| parent | c32d8656382a0eacb301692e0084377fc433ae9b (diff) | |
Update to 3.5.2 and .net core 2.1
Diffstat (limited to 'Emby.Server.Implementations/Services/ServiceController.cs')
| -rw-r--r-- | Emby.Server.Implementations/Services/ServiceController.cs | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/Emby.Server.Implementations/Services/ServiceController.cs b/Emby.Server.Implementations/Services/ServiceController.cs index 3fd6d88f8..3726c9f6b 100644 --- a/Emby.Server.Implementations/Services/ServiceController.cs +++ b/Emby.Server.Implementations/Services/ServiceController.cs @@ -50,7 +50,7 @@ namespace Emby.Server.Implementations.Services // mi.ReturnType // : Type.GetType(requestType.FullName + "Response"); - RegisterRestPaths(appHost, requestType); + RegisterRestPaths(appHost, requestType, serviceType); appHost.AddServiceInfo(serviceType, requestType); } @@ -68,14 +68,14 @@ namespace Emby.Server.Implementations.Services return null; } - public readonly Dictionary<string, List<RestPath>> RestPathMap = new Dictionary<string, List<RestPath>>(StringComparer.OrdinalIgnoreCase); + public readonly RestPath.RestPathMap RestPathMap = new RestPath.RestPathMap(); - public void RegisterRestPaths(HttpListenerHost appHost, Type requestType) + public void RegisterRestPaths(HttpListenerHost appHost, Type requestType, Type serviceType) { var attrs = appHost.GetRouteAttributes(requestType); foreach (RouteAttribute attr in attrs) { - var restPath = new RestPath(appHost.CreateInstance, appHost.GetParseFn, requestType, attr.Path, attr.Verbs, attr.IsHidden, attr.Summary, attr.Description); + var restPath = new RestPath(appHost.CreateInstance, appHost.GetParseFn, requestType, serviceType, attr.Path, attr.Verbs, attr.IsHidden, attr.Summary, attr.Description); RegisterRestPath(restPath); } @@ -114,19 +114,20 @@ namespace Emby.Server.Implementations.Services } var bestScore = -1; + RestPath bestMatch = null; foreach (var restPath in firstMatches) { var score = restPath.MatchScore(httpMethod, matchUsingPathParts, logger); - if (score > bestScore) bestScore = score; + if (score > bestScore) + { + bestScore = score; + bestMatch = restPath; + } } - if (bestScore > 0) + if (bestScore > 0 && bestMatch != null) { - foreach (var restPath in firstMatches) - { - if (bestScore == restPath.MatchScore(httpMethod, matchUsingPathParts, logger)) - return restPath; - } + return bestMatch; } } @@ -136,19 +137,21 @@ namespace Emby.Server.Implementations.Services if (!this.RestPathMap.TryGetValue(potentialHashMatch, out firstMatches)) continue; var bestScore = -1; + RestPath bestMatch = null; foreach (var restPath in firstMatches) { var score = restPath.MatchScore(httpMethod, matchUsingPathParts, logger); - if (score > bestScore) bestScore = score; - } - if (bestScore > 0) - { - foreach (var restPath in firstMatches) + if (score > bestScore) { - if (bestScore == restPath.MatchScore(httpMethod, matchUsingPathParts, logger)) - return restPath; + bestScore = score; + bestMatch = restPath; } } + + if (bestScore > 0 && bestMatch != null) + { + return bestMatch; + } } return null; |
