aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Services
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2017-08-30 14:53:37 -0400
committerGitHub <noreply@github.com>2017-08-30 14:53:37 -0400
commit00cb873164fb1619a2291e79bb53f3edcedcd731 (patch)
tree3bade7be91c556ec752a7ab8598128fa14c234d8 /Emby.Server.Implementations/Services
parent40ba8891c9ee66bb8e7dd9e8784acecd002c9c5d (diff)
parent0f23c7cfc1372ead03ab9b818e698441d4d53bd3 (diff)
Merge pull request #2855 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Server.Implementations/Services')
-rw-r--r--Emby.Server.Implementations/Services/ServiceExec.cs25
-rw-r--r--Emby.Server.Implementations/Services/ServiceMethod.cs7
-rw-r--r--Emby.Server.Implementations/Services/StringMapTypeDeserializer.cs10
3 files changed, 26 insertions, 16 deletions
diff --git a/Emby.Server.Implementations/Services/ServiceExec.cs b/Emby.Server.Implementations/Services/ServiceExec.cs
index 4a2199c89..fa9e26f28 100644
--- a/Emby.Server.Implementations/Services/ServiceExec.cs
+++ b/Emby.Server.Implementations/Services/ServiceExec.cs
@@ -24,19 +24,33 @@ namespace Emby.Server.Implementations.Services
"POLL", "SUBSCRIBE", "UNSUBSCRIBE"
});
- public static IEnumerable<MethodInfo> GetActions(this Type serviceType)
+ public static List<MethodInfo> GetActions(this Type serviceType)
{
- foreach (var mi in serviceType.GetRuntimeMethods().Where(i => i.IsPublic && !i.IsStatic))
+ var list = new List<MethodInfo>();
+
+ foreach (var mi in serviceType.GetRuntimeMethods())
{
+ if (!mi.IsPublic)
+ {
+ continue;
+ }
+
+ if (mi.IsStatic)
+ {
+ continue;
+ }
+
if (mi.GetParameters().Length != 1)
continue;
var actionName = mi.Name;
- if (!AllVerbs.Contains(actionName, StringComparer.OrdinalIgnoreCase) && !string.Equals(actionName, ServiceMethod.AnyAction, StringComparison.OrdinalIgnoreCase))
+ if (!AllVerbs.Contains(actionName, StringComparer.OrdinalIgnoreCase))
continue;
- yield return mi;
+ list.Add(mi);
}
+
+ return list;
}
}
@@ -59,8 +73,7 @@ namespace Emby.Server.Implementations.Services
var actionName = request.Verb ?? "POST";
ServiceMethod actionContext;
- if (ServiceExecGeneral.execMap.TryGetValue(ServiceMethod.Key(serviceType, actionName, requestName), out actionContext)
- || ServiceExecGeneral.execMap.TryGetValue(ServiceMethod.AnyKey(serviceType, requestName), out actionContext))
+ if (ServiceExecGeneral.execMap.TryGetValue(ServiceMethod.Key(serviceType, actionName, requestName), out actionContext))
{
if (actionContext.RequestFilters != null)
{
diff --git a/Emby.Server.Implementations/Services/ServiceMethod.cs b/Emby.Server.Implementations/Services/ServiceMethod.cs
index bcbc6fb57..fa2dd43d0 100644
--- a/Emby.Server.Implementations/Services/ServiceMethod.cs
+++ b/Emby.Server.Implementations/Services/ServiceMethod.cs
@@ -4,8 +4,6 @@ namespace Emby.Server.Implementations.Services
{
public class ServiceMethod
{
- public const string AnyAction = "ANY";
-
public string Id { get; set; }
public ActionInvokerFn ServiceAction { get; set; }
@@ -15,10 +13,5 @@ namespace Emby.Server.Implementations.Services
{
return serviceType.FullName + " " + method.ToUpper() + " " + requestDtoName;
}
-
- public static string AnyKey(Type serviceType, string requestDtoName)
- {
- return Key(serviceType, AnyAction, requestDtoName);
- }
}
} \ No newline at end of file
diff --git a/Emby.Server.Implementations/Services/StringMapTypeDeserializer.cs b/Emby.Server.Implementations/Services/StringMapTypeDeserializer.cs
index fc1cf4ed9..2233bf918 100644
--- a/Emby.Server.Implementations/Services/StringMapTypeDeserializer.cs
+++ b/Emby.Server.Implementations/Services/StringMapTypeDeserializer.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Reflection;
namespace Emby.Server.Implementations.Services
@@ -64,11 +63,16 @@ namespace Emby.Server.Implementations.Services
if (instance == null)
instance = _CreateInstanceFn(type);
- foreach (var pair in keyValuePairs.Where(x => !string.IsNullOrEmpty(x.Value)))
+ foreach (var pair in keyValuePairs)
{
propertyName = pair.Key;
propertyTextValue = pair.Value;
+ if (string.IsNullOrEmpty(propertyTextValue))
+ {
+ continue;
+ }
+
if (!propertySetterMap.TryGetValue(propertyName, out propertySerializerEntry))
{
if (propertyName == "v")
@@ -115,7 +119,7 @@ namespace Emby.Server.Implementations.Services
{
public static Action<object, object> GetSetPropertyMethod(Type type, PropertyInfo propertyInfo)
{
- if (!propertyInfo.CanWrite || propertyInfo.GetIndexParameters().Any()) return null;
+ if (!propertyInfo.CanWrite || propertyInfo.GetIndexParameters().Length > 0) return null;
var setMethodInfo = propertyInfo.SetMethod;
return (instance, value) => setMethodInfo.Invoke(instance, new[] { value });