Merge pull request #575 from EraYaN/reformat

Reformat all C# server code to conform with code standards
This commit is contained in:
Andrew Rabert
2019-01-19 15:11:50 -05:00
committed by GitHub
1591 changed files with 12161 additions and 16409 deletions

View File

@@ -1,7 +1,7 @@
using System;
using System.IO;
using Emby.Server.Implementations.HttpServer;
using System.Threading.Tasks;
using Emby.Server.Implementations.HttpServer;
namespace Emby.Server.Implementations.Services
{

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Reflection;
using System.Threading.Tasks;
using Emby.Server.Implementations.HttpServer;
using Microsoft.Extensions.Logging;
using MediaBrowser.Model.Services;
namespace Emby.Server.Implementations.Services
@@ -73,7 +72,7 @@ namespace Emby.Server.Implementations.Services
public void RegisterRestPaths(HttpListenerHost appHost, Type requestType, Type serviceType)
{
var attrs = appHost.GetRouteAttributes(requestType);
foreach (RouteAttribute attr in attrs)
foreach (var attr in attrs)
{
var restPath = new RestPath(appHost.CreateInstance, appHost.GetParseFn, requestType, serviceType, attr.Path, attr.Verbs, attr.IsHidden, attr.Summary, attr.Description);
@@ -90,8 +89,7 @@ namespace Emby.Server.Implementations.Services
if (restPath.Path.IndexOfAny(InvalidRouteChars) != -1)
throw new ArgumentException(string.Format("Route '{0}' on '{1}' contains invalid chars. ", restPath.Path, restPath.RequestType.GetMethodName()));
List<RestPath> pathsAtFirstMatch;
if (!RestPathMap.TryGetValue(restPath.FirstMatchHashKey, out pathsAtFirstMatch))
if (!RestPathMap.TryGetValue(restPath.FirstMatchHashKey, out List<RestPath> pathsAtFirstMatch))
{
pathsAtFirstMatch = new List<RestPath>();
RestPathMap[restPath.FirstMatchHashKey] = pathsAtFirstMatch;

View File

@@ -5,7 +5,6 @@ using System.Linq.Expressions;
using System.Reflection;
using System.Threading.Tasks;
using MediaBrowser.Model.Services;
using MediaBrowser.Model.Extensions;
namespace Emby.Server.Implementations.Services
{
@@ -74,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))
if (execMap.TryGetValue(ServiceMethod.Key(serviceType, actionName, requestName), out ServiceMethod actionContext))
{
if (actionContext.RequestFilters != null)
{

View File

@@ -4,8 +4,8 @@ using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Emby.Server.Implementations.HttpServer;
using Microsoft.Extensions.Logging;
using MediaBrowser.Model.Services;
using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.Services
{
@@ -62,8 +62,7 @@ namespace Emby.Server.Implementations.Services
{
if (this.RestPath == null)
{
string contentType;
this.RestPath = FindMatchingRestPath(httpMethod, pathInfo, out contentType);
this.RestPath = FindMatchingRestPath(httpMethod, pathInfo, out string contentType);
if (contentType != null)
ResponseContentType = contentType;
@@ -137,9 +136,8 @@ namespace Emby.Server.Implementations.Services
public static object CreateRequest(IRequest httpReq, RestPath restPath, Dictionary<string, string> requestParams, object requestDto)
{
string contentType;
var pathInfo = !restPath.IsWildCardPath
? GetSanitizedPathInfo(httpReq.PathInfo, out contentType)
? GetSanitizedPathInfo(httpReq.PathInfo, out string contentType)
: httpReq.PathInfo;
return restPath.CreateRequest(pathInfo, requestParams, requestDto);
@@ -239,8 +237,7 @@ namespace Emby.Server.Implementations.Services
private static RestPath GetRoute(IRequest req)
{
object route;
req.Items.TryGetValue("__route", out route);
req.Items.TryGetValue("__route", out var route);
return route as RestPath;
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
namespace Emby.Server.Implementations.Services
{
@@ -14,4 +14,4 @@ namespace Emby.Server.Implementations.Services
return serviceType.FullName + " " + method.ToUpper() + " " + requestDtoName;
}
}
}
}

View File

@@ -4,8 +4,6 @@ using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using Microsoft.Extensions.Logging;
using MediaBrowser.Model.Extensions;
namespace Emby.Server.Implementations.Services
{
@@ -308,8 +306,7 @@ namespace Emby.Server.Implementations.Services
public int MatchScore(string httpMethod, string[] withPathInfoParts)
{
int wildcardMatchCount;
var isMatch = IsMatch(httpMethod, withPathInfoParts, out wildcardMatchCount);
var isMatch = IsMatch(httpMethod, withPathInfoParts, out var wildcardMatchCount);
if (!isMatch)
{
return -1;
@@ -486,8 +483,7 @@ namespace Emby.Server.Implementations.Services
continue;
}
string propertyNameOnRequest;
if (!this.propertyNamesMap.TryGetValue(variableName.ToLower(), out propertyNameOnRequest))
if (!this.propertyNamesMap.TryGetValue(variableName.ToLower(), out var propertyNameOnRequest))
{
if (string.Equals("ignore", variableName, StringComparison.OrdinalIgnoreCase))
{

View File

@@ -11,14 +11,14 @@ namespace Emby.Server.Implementations.Services
{
internal class PropertySerializerEntry
{
public PropertySerializerEntry(Action<object,object> propertySetFn, Func<string, object> propertyParseStringFn)
public PropertySerializerEntry(Action<object, object> propertySetFn, Func<string, object> propertyParseStringFn)
{
PropertySetFn = propertySetFn;
PropertyParseStringFn = propertyParseStringFn;
}
public Action<object, object> PropertySetFn;
public Func<string,object> PropertyParseStringFn;
public Func<string, object> PropertyParseStringFn;
public Type PropertyType;
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
namespace Emby.Server.Implementations.Services
{
@@ -30,4 +30,4 @@ namespace Emby.Server.Implementations.Services
: strVal.Substring(0, pos);
}
}
}
}