mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 18:08:53 -07:00
resharper suggestions in common implementations
This commit is contained in:
parent
7806ccd42f
commit
d8263c7057
@ -149,7 +149,7 @@ namespace MediaBrowser.Common.Implementations
|
||||
protected IConfigurationManager ConfigurationManager { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BaseApplicationHost" /> class.
|
||||
/// Initializes a new instance of the <see cref="BaseApplicationHost{TApplicationPathsType}"/> class.
|
||||
/// </summary>
|
||||
protected BaseApplicationHost()
|
||||
{
|
||||
|
@ -303,6 +303,11 @@ namespace MediaBrowser.Common.Implementations
|
||||
var path = Assembly.GetExecutingAssembly().Location;
|
||||
path = Path.GetDirectoryName(path);
|
||||
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new ApplicationException("Unable to determine running assembly location");
|
||||
}
|
||||
|
||||
programDataPath = Path.Combine(path, programDataPath);
|
||||
|
||||
programDataPath = Path.GetFullPath(programDataPath);
|
||||
|
@ -1,6 +1,4 @@
|
||||
using System.Globalization;
|
||||
using System.Net.Http.Headers;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Model.Logging;
|
||||
@ -8,6 +6,7 @@ using MediaBrowser.Model.Net;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Cache;
|
||||
@ -214,7 +213,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
||||
{
|
||||
var tempFile = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid() + ".tmp");
|
||||
|
||||
return GetTempFile(options, tempFile, 0);
|
||||
return GetTempFile(options, tempFile);
|
||||
}
|
||||
|
||||
protected static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||
@ -224,11 +223,10 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
||||
/// </summary>
|
||||
/// <param name="options">The options.</param>
|
||||
/// <param name="tempFile">The temp file.</param>
|
||||
/// <param name="resumeCount">The resume count.</param>
|
||||
/// <returns>Task{System.String}.</returns>
|
||||
/// <exception cref="System.ArgumentNullException">progress</exception>
|
||||
/// <exception cref="HttpException"></exception>
|
||||
private async Task<string> GetTempFile(HttpRequestOptions options, string tempFile, int resumeCount)
|
||||
private async Task<string> GetTempFile(HttpRequestOptions options, string tempFile)
|
||||
{
|
||||
ValidateParams(options.Url, options.CancellationToken);
|
||||
|
||||
|
@ -52,10 +52,11 @@ namespace MediaBrowser.Common.Implementations.Logging
|
||||
/// <param name="level">The level.</param>
|
||||
private void AddFileTarget(string path, LogSeverity level)
|
||||
{
|
||||
var logFile = new FileTarget();
|
||||
|
||||
logFile.FileName = path;
|
||||
logFile.Layout = "${longdate}, ${level}, ${logger}, ${message}";
|
||||
var logFile = new FileTarget
|
||||
{
|
||||
FileName = path,
|
||||
Layout = "${longdate}, ${level}, ${logger}, ${message}"
|
||||
};
|
||||
|
||||
RemoveTarget("ApplicationLogFile");
|
||||
logFile.Name = "ApplicationLogFile";
|
||||
|
@ -308,11 +308,7 @@ namespace MediaBrowser.Common.Implementations.NetworkManagement
|
||||
//check if we have an IPv6 or ports
|
||||
if (values.Length <= 2) // ipv4 or hostname
|
||||
{
|
||||
if (values.Length == 1)
|
||||
//no port is specified, default
|
||||
port = defaultport;
|
||||
else
|
||||
port = GetPort(values[1]);
|
||||
port = values.Length == 1 ? defaultport : GetPort(values[1]);
|
||||
|
||||
//try to use the address as IPv4, otherwise get hostname
|
||||
if (!IPAddress.TryParse(values[0], out ipaddy))
|
||||
|
@ -45,8 +45,11 @@ namespace MediaBrowser.Common.Implementations.NetworkManagement
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="Server"></param>
|
||||
/// <param name="shi"></param>
|
||||
/// <param name="server">The server.</param>
|
||||
/// <param name="netName">Name of the net.</param>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <param name="shareType">Type of the share.</param>
|
||||
/// <param name="remark">The remark.</param>
|
||||
public Share(string server, string netName, string path, ShareType shareType, string remark)
|
||||
{
|
||||
if (ShareType.Special == shareType && "IPC$" == netName)
|
||||
@ -423,9 +426,9 @@ namespace MediaBrowser.Common.Implementations.NetworkManagement
|
||||
int nRet = 0;
|
||||
ushort entriesRead, totalEntries;
|
||||
|
||||
Type t = typeof(SHARE_INFO_50);
|
||||
int size = Marshal.SizeOf(t);
|
||||
ushort cbBuffer = (ushort)(MAX_SI50_ENTRIES * size);
|
||||
var t = typeof(SHARE_INFO_50);
|
||||
var size = Marshal.SizeOf(t);
|
||||
var cbBuffer = (ushort)(MAX_SI50_ENTRIES * size);
|
||||
//On Win9x, must allocate buffer before calling API
|
||||
IntPtr pBuffer = Marshal.AllocHGlobal(cbBuffer);
|
||||
|
||||
@ -448,16 +451,16 @@ namespace MediaBrowser.Common.Implementations.NetworkManagement
|
||||
{
|
||||
for (int i = 0, lpItem = pBuffer.ToInt32(); i < entriesRead; i++, lpItem += size)
|
||||
{
|
||||
IntPtr pItem = new IntPtr(lpItem);
|
||||
var pItem = new IntPtr(lpItem);
|
||||
|
||||
if (1 == level)
|
||||
{
|
||||
SHARE_INFO_1_9x si = (SHARE_INFO_1_9x)Marshal.PtrToStructure(pItem, t);
|
||||
var si = (SHARE_INFO_1_9x)Marshal.PtrToStructure(pItem, t);
|
||||
shares.Add(si.NetName, string.Empty, si.ShareType, si.Remark);
|
||||
}
|
||||
else
|
||||
{
|
||||
SHARE_INFO_50 si = (SHARE_INFO_50)Marshal.PtrToStructure(pItem, t);
|
||||
var si = (SHARE_INFO_50)Marshal.PtrToStructure(pItem, t);
|
||||
shares.Add(si.NetName, si.Path, si.ShareType, si.Remark);
|
||||
}
|
||||
}
|
||||
@ -542,7 +545,7 @@ namespace MediaBrowser.Common.Implementations.NetworkManagement
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="Server"></param>
|
||||
/// <param name="server">The server.</param>
|
||||
public ShareCollection(string server)
|
||||
{
|
||||
_server = server;
|
||||
@ -598,9 +601,9 @@ namespace MediaBrowser.Common.Implementations.NetworkManagement
|
||||
|
||||
Share match = null;
|
||||
|
||||
for (int i = 0; i < InnerList.Count; i++)
|
||||
foreach (object t in InnerList)
|
||||
{
|
||||
Share s = (Share)InnerList[i];
|
||||
var s = (Share)t;
|
||||
|
||||
if (s.IsFileSystem && s.MatchesPath(path))
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
|
@ -56,7 +56,17 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
|
||||
/// <param name="taskManager">The task manager.</param>
|
||||
/// <param name="jsonSerializer">The json serializer.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="serverManager">The server manager.</param>
|
||||
/// <exception cref="System.ArgumentNullException">
|
||||
/// scheduledTask
|
||||
/// or
|
||||
/// applicationPaths
|
||||
/// or
|
||||
/// taskManager
|
||||
/// or
|
||||
/// jsonSerializer
|
||||
/// or
|
||||
/// logger
|
||||
/// </exception>
|
||||
public ScheduledTaskWorker(IScheduledTask scheduledTask, IApplicationPaths applicationPaths, ITaskManager taskManager, IJsonSerializer jsonSerializer, ILogger logger)
|
||||
{
|
||||
if (scheduledTask == null)
|
||||
@ -217,7 +227,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
|
||||
{
|
||||
get
|
||||
{
|
||||
LazyInitializer.EnsureInitialized(ref _triggers, ref _triggersInitialized, ref _triggersSyncLock, () => LoadTriggers());
|
||||
LazyInitializer.EnsureInitialized(ref _triggers, ref _triggersInitialized, ref _triggersSyncLock, LoadTriggers);
|
||||
|
||||
return _triggers;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.ScheduledTasks;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@ -20,21 +19,14 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
|
||||
/// </summary>
|
||||
/// <value>The application paths.</value>
|
||||
private IApplicationPaths ApplicationPaths { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the logger.
|
||||
/// </summary>
|
||||
/// <value>The logger.</value>
|
||||
private ILogger Logger { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DeleteCacheFileTask" /> class.
|
||||
/// </summary>
|
||||
/// <param name="appPaths">The app paths.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public DeleteCacheFileTask(IApplicationPaths appPaths, ILogger logger)
|
||||
public DeleteCacheFileTask(IApplicationPaths appPaths)
|
||||
{
|
||||
ApplicationPaths = appPaths;
|
||||
Logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,6 +1,5 @@
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.ScheduledTasks;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@ -20,21 +19,14 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
|
||||
/// </summary>
|
||||
/// <value>The configuration manager.</value>
|
||||
private IConfigurationManager ConfigurationManager { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the logger.
|
||||
/// </summary>
|
||||
/// <value>The logger.</value>
|
||||
private ILogger Logger { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DeleteLogFileTask" /> class.
|
||||
/// </summary>
|
||||
/// <param name="configurationManager">The configuration manager.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public DeleteLogFileTask(IConfigurationManager configurationManager, ILogger logger)
|
||||
public DeleteLogFileTask(IConfigurationManager configurationManager)
|
||||
{
|
||||
ConfigurationManager = configurationManager;
|
||||
Logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -19,11 +19,6 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
|
||||
/// <value>The log manager.</value>
|
||||
private ILogManager LogManager { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the logger.
|
||||
/// </summary>
|
||||
/// <value>The logger.</value>
|
||||
private ILogger Logger { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the configuration manager.
|
||||
/// </summary>
|
||||
/// <value>The configuration manager.</value>
|
||||
@ -33,12 +28,10 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
|
||||
/// Initializes a new instance of the <see cref="ReloadLoggerFileTask" /> class.
|
||||
/// </summary>
|
||||
/// <param name="logManager">The logManager.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="configurationManager">The configuration manager.</param>
|
||||
public ReloadLoggerFileTask(ILogManager logManager, ILogger logger, IConfigurationManager configurationManager)
|
||||
public ReloadLoggerFileTask(ILogManager logManager, IConfigurationManager configurationManager)
|
||||
{
|
||||
LogManager = logManager;
|
||||
Logger = logger;
|
||||
ConfigurationManager = configurationManager;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user