From dd9404ebc6e2e03bb4f0135e48a59211252615d9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 30 Aug 2017 23:49:38 -0400 Subject: update skiasharp to 1.58.1 --- .../Services/ServicePath.cs | 124 ++++++++++----------- 1 file changed, 59 insertions(+), 65 deletions(-) (limited to 'Emby.Server.Implementations/Services/ServicePath.cs') diff --git a/Emby.Server.Implementations/Services/ServicePath.cs b/Emby.Server.Implementations/Services/ServicePath.cs index da5e74f1f..df5d71374 100644 --- a/Emby.Server.Implementations/Services/ServicePath.cs +++ b/Emby.Server.Implementations/Services/ServicePath.cs @@ -21,8 +21,6 @@ namespace Emby.Server.Implementations.Services readonly bool[] componentsWithSeparators; private readonly string restPath; - private readonly string allowedVerbs; - private readonly bool allowsAllVerbs; public bool IsWildCardPath { get; private set; } private readonly string[] literalsToMatch; @@ -46,15 +44,7 @@ namespace Emby.Server.Implementations.Services /// public int TotalComponentsCount { get; set; } - public string[] Verbs - { - get - { - return allowsAllVerbs - ? new[] { "ANY" } - : AllowedVerbs.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); - } - } + public string[] Verbs { get; private set; } public Type RequestType { get; private set; } @@ -62,19 +52,11 @@ namespace Emby.Server.Implementations.Services public string Summary { get; private set; } - public string Notes { get; private set; } - - public bool AllowsAllVerbs { get { return this.allowsAllVerbs; } } - - public string AllowedVerbs { get { return this.allowedVerbs; } } - public int Priority { get; set; } //passed back to RouteAttribute public static string[] GetPathPartsForMatching(string pathInfo) { - var parts = pathInfo.ToLower().Split(PathSeperatorChar) - .Where(x => !String.IsNullOrEmpty(x)).ToArray(); - return parts; + return pathInfo.ToLower().Split(new[] { PathSeperatorChar }, StringSplitOptions.RemoveEmptyEntries); } public static List GetFirstMatchHashKeys(string[] pathPartsForMatching) @@ -109,18 +91,13 @@ namespace Emby.Server.Implementations.Services return list; } - public RestPath(Func createInstanceFn, Func> getParseFn, Type requestType, string path, string verbs, string summary = null, string notes = null) + public RestPath(Func createInstanceFn, Func> getParseFn, Type requestType, string path, string verbs, string summary = null) { this.RequestType = requestType; this.Summary = summary; - this.Notes = notes; this.restPath = path; - this.allowsAllVerbs = verbs == null || String.Equals(verbs, WildCard, StringComparison.OrdinalIgnoreCase); - if (!this.allowsAllVerbs) - { - this.allowedVerbs = verbs.ToUpper(); - } + this.Verbs = string.IsNullOrWhiteSpace(verbs) ? ServiceExecExtensions.AllVerbs : verbs.ToUpper().Split(new[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries); var componentsList = new List(); @@ -153,7 +130,6 @@ namespace Emby.Server.Implementations.Services this.PathComponentsCount = this.componentsWithSeparators.Length; string firstLiteralMatch = null; - var sbHashKey = new StringBuilder(); for (var i = 0; i < components.Length; i++) { var component = components[i]; @@ -172,7 +148,6 @@ namespace Emby.Server.Implementations.Services else { this.literalsToMatch[i] = component.ToLower(); - sbHashKey.Append(i + PathSeperatorChar.ToString() + this.literalsToMatch); if (firstLiteralMatch == null) { @@ -198,9 +173,6 @@ namespace Emby.Server.Implementations.Services ? this.PathComponentsCount + PathSeperator + firstLiteralMatch : WildCardChar + PathSeperator + firstLiteralMatch; - this.IsValid = sbHashKey.Length > 0; - this.UniqueMatchHashKey = sbHashKey.ToString(); - this.typeDeserializer = new StringMapTypeDeserializer(createInstanceFn, getParseFn, this.RequestType); RegisterCaseInsenstivePropertyNameMappings(); } @@ -220,26 +192,46 @@ namespace Emby.Server.Implementations.Services }; - private static List _excludeTypes = new List { typeof(Stream) }; + private static Type excludeType = typeof(Stream); - internal static PropertyInfo[] GetSerializableProperties(Type type) + internal static List GetSerializableProperties(Type type) { - var properties = GetPublicProperties(type); - var readableProperties = properties.Where(x => x.GetMethod != null); + var list = new List(); + var props = GetPublicProperties(type); - // else return those properties that are not decorated with IgnoreDataMember - return readableProperties - .Where(prop => prop.GetCustomAttributes(true) - .All(attr => + foreach (var prop in props) + { + if (prop.GetMethod == null) + { + continue; + } + + if (excludeType == prop.PropertyType) + { + continue; + } + + var ignored = false; + foreach (var attr in prop.GetCustomAttributes(true)) + { + if (IgnoreAttributesNamed.Contains(attr.GetType().Name)) { - var name = attr.GetType().Name; - return !IgnoreAttributesNamed.Contains(name); - })) - .Where(prop => !_excludeTypes.Contains(prop.PropertyType)) - .ToArray(); + ignored = true; + break; + } + } + + if (!ignored) + { + list.Add(prop); + } + } + + // else return those properties that are not decorated with IgnoreDataMember + return list; } - private static PropertyInfo[] GetPublicProperties(Type type) + private static List GetPublicProperties(Type type) { if (type.GetTypeInfo().IsInterface) { @@ -269,12 +261,19 @@ namespace Emby.Server.Implementations.Services propertyInfos.InsertRange(0, newPropertyInfos); } - return propertyInfos.ToArray(propertyInfos.Count); + return propertyInfos; } - return GetTypesPublicProperties(type) - .Where(t => t.GetIndexParameters().Length == 0) // ignore indexed properties - .ToArray(); + var list = new List(); + + foreach (var t in GetTypesPublicProperties(type)) + { + if (t.GetIndexParameters().Length == 0) + { + list.Add(t); + } + } + return list; } private static PropertyInfo[] GetTypesPublicProperties(Type subType) @@ -289,16 +288,11 @@ namespace Emby.Server.Implementations.Services return pis.ToArray(pis.Count); } - - public bool IsValid { get; set; } - /// /// Provide for quick lookups based on hashes that can be determined from a request url /// public string FirstMatchHashKey { get; private set; } - public string UniqueMatchHashKey { get; private set; } - private readonly StringMapTypeDeserializer typeDeserializer; private readonly Dictionary propertyNamesMap = new Dictionary(); @@ -321,8 +315,14 @@ namespace Emby.Server.Implementations.Services score += Math.Max((10 - VariableArgsCount), 1) * 100; //Exact verb match is better than ANY - var exactVerb = String.Equals(httpMethod, AllowedVerbs, StringComparison.OrdinalIgnoreCase); - score += exactVerb ? 10 : 1; + if (Verbs.Length == 1 && string.Equals(httpMethod, Verbs[0], StringComparison.OrdinalIgnoreCase)) + { + score += 10; + } + else + { + score += 1; + } return score; } @@ -346,7 +346,7 @@ namespace Emby.Server.Implementations.Services return false; } - if (!this.allowsAllVerbs && !StringContains(this.allowedVerbs, httpMethod)) + if (!Verbs.Contains(httpMethod, StringComparer.OrdinalIgnoreCase)) { //logger.Info("allowsAllVerbs mismatch for {0} for {1} allowedverbs {2}", httpMethod, string.Join("/", withPathInfoParts), this.allowedVerbs); return false; @@ -457,8 +457,7 @@ namespace Emby.Server.Implementations.Services public object CreateRequest(string pathInfo, Dictionary queryStringAndFormData, object fromInstance) { - var requestComponents = pathInfo.Split(PathSeperatorChar) - .Where(x => !String.IsNullOrEmpty(x)).ToArray(); + var requestComponents = pathInfo.Split(new[] { PathSeperatorChar }, StringSplitOptions.RemoveEmptyEntries); ExplodeComponents(ref requestComponents); @@ -555,10 +554,5 @@ namespace Emby.Server.Implementations.Services return this.typeDeserializer.PopulateFromMap(fromInstance, requestKeyValuesMap); } - - public override int GetHashCode() - { - return UniqueMatchHashKey.GetHashCode(); - } } } \ No newline at end of file -- cgit v1.2.3 From 2f99a78230b397535d7ea0b9e335a00b438379b4 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 11 Sep 2017 15:25:13 -0400 Subject: 3.2.30.17 --- Emby.Server.Implementations/Services/ServiceController.cs | 2 +- Emby.Server.Implementations/Services/ServicePath.cs | 6 +++++- Emby.Server.Implementations/Services/SwaggerService.cs | 14 ++++++++++---- MediaBrowser.Api/PluginService.cs | 10 +++++----- MediaBrowser.Model/Services/RouteAttribute.cs | 4 ++++ MediaBrowser.WebDashboard/Api/DashboardService.cs | 8 ++++---- SharedVersion.cs | 2 +- 7 files changed, 30 insertions(+), 16 deletions(-) (limited to 'Emby.Server.Implementations/Services/ServicePath.cs') diff --git a/Emby.Server.Implementations/Services/ServiceController.cs b/Emby.Server.Implementations/Services/ServiceController.cs index 4dc14a193..3fd6d88f8 100644 --- a/Emby.Server.Implementations/Services/ServiceController.cs +++ b/Emby.Server.Implementations/Services/ServiceController.cs @@ -75,7 +75,7 @@ namespace Emby.Server.Implementations.Services var attrs = appHost.GetRouteAttributes(requestType); foreach (RouteAttribute attr in attrs) { - var restPath = new RestPath(appHost.CreateInstance, appHost.GetParseFn, requestType, attr.Path, attr.Verbs, attr.Summary); + var restPath = new RestPath(appHost.CreateInstance, appHost.GetParseFn, requestType, attr.Path, attr.Verbs, attr.IsHidden, attr.Summary, attr.Description); RegisterRestPath(restPath); } diff --git a/Emby.Server.Implementations/Services/ServicePath.cs b/Emby.Server.Implementations/Services/ServicePath.cs index df5d71374..0ca36df19 100644 --- a/Emby.Server.Implementations/Services/ServicePath.cs +++ b/Emby.Server.Implementations/Services/ServicePath.cs @@ -51,6 +51,8 @@ namespace Emby.Server.Implementations.Services public string Path { get { return this.restPath; } } public string Summary { get; private set; } + public string Description { get; private set; } + public bool IsHidden { get; private set; } public int Priority { get; set; } //passed back to RouteAttribute @@ -91,10 +93,12 @@ namespace Emby.Server.Implementations.Services return list; } - public RestPath(Func createInstanceFn, Func> getParseFn, Type requestType, string path, string verbs, string summary = null) + public RestPath(Func createInstanceFn, Func> getParseFn, Type requestType, string path, string verbs, bool isHidden = false, string summary = null, string description = null) { this.RequestType = requestType; this.Summary = summary; + this.IsHidden = isHidden; + this.Description = description; this.restPath = path; this.Verbs = string.IsNullOrWhiteSpace(verbs) ? ServiceExecExtensions.AllVerbs : verbs.ToUpper().Split(new[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries); diff --git a/Emby.Server.Implementations/Services/SwaggerService.cs b/Emby.Server.Implementations/Services/SwaggerService.cs index 63cbb78dd..be3b4cbba 100644 --- a/Emby.Server.Implementations/Services/SwaggerService.cs +++ b/Emby.Server.Implementations/Services/SwaggerService.cs @@ -21,7 +21,7 @@ namespace Emby.Server.Implementations.Services public string host { get; set; } public string basePath { get; set; } public SwaggerTag[] tags { get; set; } - public Dictionary> paths { get; set; } + public IDictionary> paths { get; set; } public Dictionary definitions { get; set; } } @@ -147,16 +147,21 @@ namespace Emby.Server.Implementations.Services return new Dictionary(); } - private Dictionary> GetPaths() + private IDictionary> GetPaths() { - var paths = new Dictionary>(); + var paths = new SortedDictionary>(); - var all = ServiceController.Instance.RestPathMap.ToList(); + var all = ServiceController.Instance.RestPathMap.OrderBy(i => i.Key, StringComparer.OrdinalIgnoreCase).ToList(); foreach (var current in all) { foreach (var info in current.Value) { + if (info.IsHidden) + { + continue; + } + if (info.Path.StartsWith("/mediabrowser", StringComparison.OrdinalIgnoreCase)) { continue; @@ -191,6 +196,7 @@ namespace Emby.Server.Implementations.Services result[verb.ToLower()] = new SwaggerMethod { summary = info.Summary, + description = info.Description, produces = new[] { "application/json" diff --git a/MediaBrowser.Api/PluginService.cs b/MediaBrowser.Api/PluginService.cs index f6efe15e6..1eea89431 100644 --- a/MediaBrowser.Api/PluginService.cs +++ b/MediaBrowser.Api/PluginService.cs @@ -82,7 +82,7 @@ namespace MediaBrowser.Api /// /// Class GetPluginSecurityInfo /// - [Route("/Plugins/SecurityInfo", "GET", Summary = "Gets plugin registration information")] + [Route("/Plugins/SecurityInfo", "GET", Summary = "Gets plugin registration information", IsHidden = true)] [Authenticated] public class GetPluginSecurityInfo : IReturn { @@ -91,13 +91,13 @@ namespace MediaBrowser.Api /// /// Class UpdatePluginSecurityInfo /// - [Route("/Plugins/SecurityInfo", "POST", Summary = "Updates plugin registration information")] + [Route("/Plugins/SecurityInfo", "POST", Summary = "Updates plugin registration information", IsHidden = true)] [Authenticated(Roles = "Admin")] public class UpdatePluginSecurityInfo : PluginSecurityInfo, IReturnVoid { } - [Route("/Plugins/RegistrationRecords/{Name}", "GET", Summary = "Gets registration status for a feature")] + [Route("/Plugins/RegistrationRecords/{Name}", "GET", Summary = "Gets registration status for a feature", IsHidden = true)] [Authenticated] public class GetRegistrationStatus { @@ -108,7 +108,7 @@ namespace MediaBrowser.Api public string Mb2Equivalent { get; set; } } - [Route("/Registrations/{Name}", "GET", Summary = "Gets registration status for a feature")] + [Route("/Registrations/{Name}", "GET", Summary = "Gets registration status for a feature", IsHidden = true)] [Authenticated] public class GetRegistration : IReturn { @@ -116,7 +116,7 @@ namespace MediaBrowser.Api public string Name { get; set; } } - [Route("/Appstore/Register", "POST", Summary = "Registers an appstore sale")] + [Route("/Appstore/Register", "POST", Summary = "Registers an appstore sale", IsHidden = true)] [Authenticated] public class RegisterAppstoreSale { diff --git a/MediaBrowser.Model/Services/RouteAttribute.cs b/MediaBrowser.Model/Services/RouteAttribute.cs index 5a39688da..264500e60 100644 --- a/MediaBrowser.Model/Services/RouteAttribute.cs +++ b/MediaBrowser.Model/Services/RouteAttribute.cs @@ -88,6 +88,10 @@ namespace MediaBrowser.Model.Services /// public string Summary { get; set; } + public string Description { get; set; } + + public bool IsHidden { get; set; } + /// /// Gets or sets longer text to explain the behaviour of the route. /// diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index c6bbca672..d4d0e281e 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -47,13 +47,13 @@ namespace MediaBrowser.WebDashboard.Api public string Name { get; set; } } - [Route("/web/Package", "GET")] + [Route("/web/Package", "GET", IsHidden = true)] public class GetDashboardPackage { public string Mode { get; set; } } - [Route("/robots.txt", "GET")] + [Route("/robots.txt", "GET", IsHidden = true)] public class GetRobotsTxt { } @@ -61,7 +61,7 @@ namespace MediaBrowser.WebDashboard.Api /// /// Class GetDashboardResource /// - [Route("/web/{ResourceName*}", "GET")] + [Route("/web/{ResourceName*}", "GET", IsHidden = true)] public class GetDashboardResource { /// @@ -76,7 +76,7 @@ namespace MediaBrowser.WebDashboard.Api public string V { get; set; } } - [Route("/favicon.ico", "GET")] + [Route("/favicon.ico", "GET", IsHidden = true)] public class GetFavIcon { } diff --git a/SharedVersion.cs b/SharedVersion.cs index 279897349..e851e6488 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.30.16")] +[assembly: AssemblyVersion("3.2.30.17")] -- cgit v1.2.3