aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations
diff options
context:
space:
mode:
authorErwin de Haan <EraYaN@users.noreply.github.com>2019-01-06 21:50:43 +0100
committerErwin de Haan <EraYaN@users.noreply.github.com>2019-01-10 20:38:53 +0100
commitec1f5dc317182582ebff843c9e8a4d5277405469 (patch)
tree6514de336cc9aa94becb3fbd767285dfa61d0b1b /Emby.Server.Implementations
parent3d867c2c46cec39b669bb8647efef677f32b8a8d (diff)
Mayor code cleanup
Add Argument*Exceptions now use proper nameof operators. Added exception messages to quite a few Argument*Exceptions. Fixed rethorwing to be proper syntax. Added a ton of null checkes. (This is only a start, there are about 500 places that need proper null handling) Added some TODOs to log certain exceptions. Fix sln again. Fixed all AssemblyInfo's and added proper copyright (where I could find them) We live in *current year*. Fixed the use of braces. Fixed a ton of properties, and made a fair amount of functions static that should be and can be static. Made more Methods that should be static static. You can now use static to find bad functions! Removed unused variable. And added one more proper XML comment.
Diffstat (limited to 'Emby.Server.Implementations')
-rw-r--r--Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs8
-rw-r--r--Emby.Server.Implementations/Activity/ActivityRepository.cs8
-rw-r--r--Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs71
-rw-r--r--Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs5
-rw-r--r--Emby.Server.Implementations/AppBase/ConfigurationHelper.cs3
-rw-r--r--Emby.Server.Implementations/ApplicationHost.cs86
-rw-r--r--Emby.Server.Implementations/Channels/ChannelImageProvider.cs5
-rw-r--r--Emby.Server.Implementations/Channels/ChannelManager.cs23
-rw-r--r--Emby.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs35
-rw-r--r--Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs15
-rw-r--r--Emby.Server.Implementations/Data/BaseSqliteRepository.cs33
-rw-r--r--Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs16
-rw-r--r--Emby.Server.Implementations/Data/SqliteExtensions.cs4
-rw-r--r--Emby.Server.Implementations/Data/SqliteItemRepository.cs68
-rw-r--r--Emby.Server.Implementations/Data/SqliteUserDataRepository.cs44
-rw-r--r--Emby.Server.Implementations/Data/SqliteUserRepository.cs15
-rw-r--r--Emby.Server.Implementations/Data/TypeMapper.cs2
-rw-r--r--Emby.Server.Implementations/Devices/DeviceId.cs16
-rw-r--r--Emby.Server.Implementations/Devices/DeviceManager.cs11
-rw-r--r--Emby.Server.Implementations/Diagnostics/CommonProcess.cs25
-rw-r--r--Emby.Server.Implementations/Dto/DtoService.cs18
-rw-r--r--Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs4
-rw-r--r--Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs6
-rw-r--r--Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs4
-rw-r--r--Emby.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs5
-rw-r--r--Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs10
-rw-r--r--Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs26
-rw-r--r--Emby.Server.Implementations/HttpServer/FileWriter.cs11
-rw-r--r--Emby.Server.Implementations/HttpServer/HttpListenerHost.cs33
-rw-r--r--Emby.Server.Implementations/HttpServer/HttpResultFactory.cs24
-rw-r--r--Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs15
-rw-r--r--Emby.Server.Implementations/HttpServer/Security/AuthService.cs6
-rw-r--r--Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs4
-rw-r--r--Emby.Server.Implementations/HttpServer/StreamWriter.cs9
-rw-r--r--Emby.Server.Implementations/HttpServer/WebSocketConnection.cs22
-rw-r--r--Emby.Server.Implementations/IO/FileRefresher.cs4
-rw-r--r--Emby.Server.Implementations/IO/IsoManager.cs2
-rw-r--r--Emby.Server.Implementations/IO/LibraryMonitor.cs10
-rw-r--r--Emby.Server.Implementations/IO/ManagedFileSystem.cs50
-rw-r--r--Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs11
-rw-r--r--Emby.Server.Implementations/IO/ThrottledStream.cs59
-rw-r--r--Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs19
-rw-r--r--Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs2
-rw-r--r--Emby.Server.Implementations/Library/LibraryManager.cs61
-rw-r--r--Emby.Server.Implementations/Library/MediaSourceManager.cs19
-rw-r--r--Emby.Server.Implementations/Library/PathExtensions.cs4
-rw-r--r--Emby.Server.Implementations/Library/ResolverHelper.cs6
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs11
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs9
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs9
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/FolderResolver.cs5
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/ItemResolver.cs8
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs4
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs20
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs9
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs5
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs5
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs14
-rw-r--r--Emby.Server.Implementations/Library/SearchEngine.cs6
-rw-r--r--Emby.Server.Implementations/Library/UserDataManager.cs10
-rw-r--r--Emby.Server.Implementations/Library/UserManager.cs45
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs41
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs16
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs6
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs4
-rw-r--r--Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs35
-rw-r--r--Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs26
-rw-r--r--Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs11
-rw-r--r--Emby.Server.Implementations/LiveTv/LiveTvManager.cs24
-rw-r--r--Emby.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs35
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs23
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs31
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs28
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs62
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs8
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs10
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs8
-rw-r--r--Emby.Server.Implementations/Localization/LocalizationManager.cs18
-rw-r--r--Emby.Server.Implementations/Localization/TextLocalizer.cs4
-rw-r--r--Emby.Server.Implementations/MediaEncoder/EncodingManager.cs6
-rw-r--r--Emby.Server.Implementations/Net/DisposableManagedObjectBase.cs8
-rw-r--r--Emby.Server.Implementations/Net/SocketFactory.cs46
-rw-r--r--Emby.Server.Implementations/Net/UdpSocket.cs9
-rw-r--r--Emby.Server.Implementations/Networking/IPNetwork/IPAddressCollection.cs20
-rw-r--r--Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs142
-rw-r--r--Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs36
-rw-r--r--Emby.Server.Implementations/Networking/NetworkManager.cs37
-rw-r--r--Emby.Server.Implementations/Playlists/ManualPlaylistsFolder.cs21
-rw-r--r--Emby.Server.Implementations/Playlists/PlaylistManager.cs17
-rw-r--r--Emby.Server.Implementations/Properties/AssemblyInfo.cs23
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs27
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/PeopleValidationTask.cs26
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/RefreshMediaLibraryTask.cs23
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs44
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs38
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs38
-rw-r--r--Emby.Server.Implementations/Security/AuthenticationRepository.cs16
-rw-r--r--Emby.Server.Implementations/Security/EncryptionManager.cs16
-rw-r--r--Emby.Server.Implementations/Security/MBLicenseFile.cs10
-rw-r--r--Emby.Server.Implementations/Security/PluginSecurityManager.cs19
-rw-r--r--Emby.Server.Implementations/Serialization/JsonSerializer.cs40
-rw-r--r--Emby.Server.Implementations/ServerApplicationPaths.cs149
-rw-r--r--Emby.Server.Implementations/Services/HttpResult.cs4
-rw-r--r--Emby.Server.Implementations/Services/ServicePath.cs26
-rw-r--r--Emby.Server.Implementations/Session/HttpSessionController.cs25
-rw-r--r--Emby.Server.Implementations/Session/SessionManager.cs43
-rw-r--r--Emby.Server.Implementations/Session/SessionWebSocketListener.cs5
-rw-r--r--Emby.Server.Implementations/Session/WebSocketController.cs18
-rw-r--r--Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs23
-rw-r--r--Emby.Server.Implementations/Sorting/AlbumArtistComparer.cs9
-rw-r--r--Emby.Server.Implementations/Sorting/AlbumComparer.cs7
-rw-r--r--Emby.Server.Implementations/Sorting/ArtistComparer.cs7
-rw-r--r--Emby.Server.Implementations/Sorting/CommunityRatingComparer.cs12
-rw-r--r--Emby.Server.Implementations/Sorting/CriticRatingComparer.cs7
-rw-r--r--Emby.Server.Implementations/Sorting/DateCreatedComparer.cs11
-rw-r--r--Emby.Server.Implementations/Sorting/DateLastMediaAddedComparer.cs9
-rw-r--r--Emby.Server.Implementations/Sorting/DatePlayedComparer.cs5
-rw-r--r--Emby.Server.Implementations/Sorting/GameSystemComparer.cs7
-rw-r--r--Emby.Server.Implementations/Sorting/IsFavoriteOrLikeComparer.cs5
-rw-r--r--Emby.Server.Implementations/Sorting/IsFolderComparer.cs7
-rw-r--r--Emby.Server.Implementations/Sorting/IsPlayedComparer.cs5
-rw-r--r--Emby.Server.Implementations/Sorting/IsUnplayedComparer.cs5
-rw-r--r--Emby.Server.Implementations/Sorting/NameComparer.cs11
-rw-r--r--Emby.Server.Implementations/Sorting/OfficialRatingComparer.cs12
-rw-r--r--Emby.Server.Implementations/Sorting/PlayCountComparer.cs5
-rw-r--r--Emby.Server.Implementations/Sorting/PlayersComparer.cs7
-rw-r--r--Emby.Server.Implementations/Sorting/PremiereDateComparer.cs7
-rw-r--r--Emby.Server.Implementations/Sorting/ProductionYearComparer.cs7
-rw-r--r--Emby.Server.Implementations/Sorting/RandomComparer.cs5
-rw-r--r--Emby.Server.Implementations/Sorting/RuntimeComparer.cs12
-rw-r--r--Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs9
-rw-r--r--Emby.Server.Implementations/Sorting/SortNameComparer.cs11
-rw-r--r--Emby.Server.Implementations/Sorting/StartDateComparer.cs7
-rw-r--r--Emby.Server.Implementations/Sorting/StudioComparer.cs11
-rw-r--r--Emby.Server.Implementations/TV/TVSeriesManager.cs8
-rw-r--r--Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/CharExtensions.cs2
-rw-r--r--Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/StringExtensions.cs8
-rw-r--r--Emby.Server.Implementations/TextEncoding/NLangDetect/LanguageDetector.cs2
-rw-r--r--Emby.Server.Implementations/TextEncoding/TextEncoding.cs13
-rw-r--r--Emby.Server.Implementations/TextEncoding/TextEncodingDetect.cs5
-rw-r--r--Emby.Server.Implementations/TextEncoding/UniversalDetector/CharsetDetector.cs10
-rw-r--r--Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/CodingStateMachine.cs10
-rw-r--r--Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/SMModel.cs10
-rw-r--r--Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/SequenceModel.cs22
-rw-r--r--Emby.Server.Implementations/Udp/UdpServer.cs8
-rw-r--r--Emby.Server.Implementations/Updates/InstallationManager.cs23
-rw-r--r--Emby.Server.Implementations/UserViews/DynamicImageProvider.cs4
147 files changed, 938 insertions, 1829 deletions
diff --git a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs
index 3f7b907a9..eca1ff0f5 100644
--- a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs
+++ b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs
@@ -202,7 +202,7 @@ namespace Emby.Server.Implementations.Activity
return name;
}
- private string GetPlaybackNotificationType(string mediaType)
+ private static string GetPlaybackNotificationType(string mediaType)
{
if (string.Equals(mediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase))
{
@@ -220,7 +220,7 @@ namespace Emby.Server.Implementations.Activity
return null;
}
- private string GetPlaybackStoppedNotificationType(string mediaType)
+ private static string GetPlaybackStoppedNotificationType(string mediaType)
{
if (string.Equals(mediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase))
{
@@ -577,8 +577,8 @@ namespace Emby.Server.Implementations.Activity
/// <param name="description">The name of this item (singular form)</param>
private static string CreateValueString(int value, string description)
{
- return String.Format("{0:#,##0} {1}",
- value, value == 1 ? description : String.Format("{0}s", description));
+ return string.Format("{0:#,##0} {1}",
+ value, value == 1 ? description : string.Format("{0}s", description));
}
}
}
diff --git a/Emby.Server.Implementations/Activity/ActivityRepository.cs b/Emby.Server.Implementations/Activity/ActivityRepository.cs
index 91a4a5fd4..822219132 100644
--- a/Emby.Server.Implementations/Activity/ActivityRepository.cs
+++ b/Emby.Server.Implementations/Activity/ActivityRepository.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
@@ -83,7 +83,7 @@ namespace Emby.Server.Implementations.Activity
{
if (entry == null)
{
- throw new ArgumentNullException("entry");
+ throw new ArgumentNullException(nameof(entry));
}
using (WriteLock.Write())
@@ -122,7 +122,7 @@ namespace Emby.Server.Implementations.Activity
{
if (entry == null)
{
- throw new ArgumentNullException("entry");
+ throw new ArgumentNullException(nameof(entry));
}
using (WriteLock.Write())
@@ -251,7 +251,7 @@ namespace Emby.Server.Implementations.Activity
}
}
- private ActivityLogEntry GetEntry(IReadOnlyList<IResultSetValue> reader)
+ private static ActivityLogEntry GetEntry(IReadOnlyList<IResultSetValue> reader)
{
var index = 0;
diff --git a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
index 3e12bc0b6..3ad2d4b91 100644
--- a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
+++ b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
@@ -55,61 +55,31 @@ namespace Emby.Server.Implementations.AppBase
}
private const string _virtualDataPath = "%AppDataPath%";
- public string VirtualDataPath
- {
- get
- {
- return _virtualDataPath;
- }
- }
+ public string VirtualDataPath => _virtualDataPath;
/// <summary>
/// Gets the image cache path.
/// </summary>
/// <value>The image cache path.</value>
- public string ImageCachePath
- {
- get
- {
- return Path.Combine(CachePath, "images");
- }
- }
+ public string ImageCachePath => Path.Combine(CachePath, "images");
/// <summary>
/// Gets the path to the plugin directory
/// </summary>
/// <value>The plugins path.</value>
- public string PluginsPath
- {
- get
- {
- return Path.Combine(ProgramDataPath, "plugins");
- }
- }
+ public string PluginsPath => Path.Combine(ProgramDataPath, "plugins");
/// <summary>
/// Gets the path to the plugin configurations directory
/// </summary>
/// <value>The plugin configurations path.</value>
- public string PluginConfigurationsPath
- {
- get
- {
- return Path.Combine(PluginsPath, "configurations");
- }
- }
+ public string PluginConfigurationsPath => Path.Combine(PluginsPath, "configurations");
/// <summary>
/// Gets the path to where temporary update files will be stored
/// </summary>
/// <value>The plugin configurations path.</value>
- public string TempUpdatePath
- {
- get
- {
- return Path.Combine(ProgramDataPath, "updates");
- }
- }
+ public string TempUpdatePath => Path.Combine(ProgramDataPath, "updates");
/// <summary>
/// The _log directory
@@ -133,10 +103,7 @@ namespace Emby.Server.Implementations.AppBase
return _logDirectoryPath;
}
- set
- {
- _logDirectoryPath = value;
- }
+ set => _logDirectoryPath = value;
}
/// <summary>
@@ -161,23 +128,14 @@ namespace Emby.Server.Implementations.AppBase
return _configurationDirectoryPath;
}
- set
- {
- _configurationDirectoryPath = value;
- }
+ set => _configurationDirectoryPath = value;
}
/// <summary>
/// Gets the path to the system configuration file
/// </summary>
/// <value>The system configuration file path.</value>
- public string SystemConfigurationFilePath
- {
- get
- {
- return Path.Combine(ConfigurationDirectoryPath, "system.xml");
- }
- }
+ public string SystemConfigurationFilePath => Path.Combine(ConfigurationDirectoryPath, "system.xml");
/// <summary>
/// The _cache directory
@@ -200,22 +158,13 @@ namespace Emby.Server.Implementations.AppBase
return _cachePath;
}
- set
- {
- _cachePath = value;
- }
+ set => _cachePath = value;
}
/// <summary>
/// Gets the folder path to the temp directory within the cache folder
/// </summary>
/// <value>The temp directory.</value>
- public string TempDirectory
- {
- get
- {
- return Path.Combine(CachePath, "temp");
- }
- }
+ public string TempDirectory => Path.Combine(CachePath, "temp");
}
}
diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
index bc5168fe8..222a93a10 100644
--- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
+++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
@@ -99,6 +99,7 @@ namespace Emby.Server.Implementations.AppBase
/// <param name="applicationPaths">The application paths.</param>
/// <param name="loggerFactory">The logger factory.</param>
/// <param name="xmlSerializer">The XML serializer.</param>
+ /// <param name="fileSystem">The file system</param>
protected BaseConfigurationManager(IApplicationPaths applicationPaths, ILoggerFactory loggerFactory, IXmlSerializer xmlSerializer, IFileSystem fileSystem)
{
CommonApplicationPaths = applicationPaths;
@@ -155,7 +156,7 @@ namespace Emby.Server.Implementations.AppBase
{
if (newConfiguration == null)
{
- throw new ArgumentNullException("newConfiguration");
+ throw new ArgumentNullException(nameof(newConfiguration));
}
ValidateCachePath(newConfiguration);
diff --git a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs
index d6a41dd67..ee6da95fe 100644
--- a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs
+++ b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.IO;
using System.Linq;
using MediaBrowser.Model.IO;
@@ -18,6 +18,7 @@ namespace Emby.Server.Implementations.AppBase
/// <param name="type">The type.</param>
/// <param name="path">The path.</param>
/// <param name="xmlSerializer">The XML serializer.</param>
+ /// <param name="fileSystem">The file system</param>
/// <returns>System.Object.</returns>
public static object GetXmlConfiguration(Type type, string path, IXmlSerializer xmlSerializer, IFileSystem fileSystem)
{
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index b020b33c3..386f42959 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -1,4 +1,4 @@
-using Emby.Common.Implementations.Serialization;
+using Emby.Common.Implementations.Serialization;
using Emby.Drawing;
using Emby.Photos;
using Emby.Dlna;
@@ -132,13 +132,7 @@ namespace Emby.Server.Implementations
/// Gets or sets a value indicating whether this instance can self update.
/// </summary>
/// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
- public virtual bool CanSelfUpdate
- {
- get
- {
- return false;
- }
- }
+ public virtual bool CanSelfUpdate => false;
public virtual bool CanLaunchWebBrowser
{
@@ -245,10 +239,7 @@ namespace Emby.Server.Implementations
}
}
- public virtual string OperatingSystemDisplayName
- {
- get { return EnvironmentInfo.OperatingSystemName; }
- }
+ public virtual string OperatingSystemDisplayName => EnvironmentInfo.OperatingSystemName;
/// <summary>
/// The container
@@ -261,10 +252,7 @@ namespace Emby.Server.Implementations
/// Gets the server configuration manager.
/// </summary>
/// <value>The server configuration manager.</value>
- public IServerConfigurationManager ServerConfigurationManager
- {
- get { return (IServerConfigurationManager)ConfigurationManager; }
- }
+ public IServerConfigurationManager ServerConfigurationManager => (IServerConfigurationManager)ConfigurationManager;
/// <summary>
/// Gets the configuration manager.
@@ -453,13 +441,7 @@ namespace Emby.Server.Implementations
/// Gets the current application version
/// </summary>
/// <value>The application version.</value>
- public Version ApplicationVersion
- {
- get
- {
- return _version ?? (_version = typeof(ApplicationHost).Assembly.GetName().Version);
- }
- }
+ public Version ApplicationVersion => _version ?? (_version = typeof(ApplicationHost).Assembly.GetName().Version);
private DeviceId _deviceId;
public string SystemId
@@ -479,15 +461,9 @@ namespace Emby.Server.Implementations
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get
- {
- return "Emby Server";
- }
- }
+ public string Name => "Emby Server";
- private Tuple<Assembly, string> GetAssembly(Type type)
+ private static Tuple<Assembly, string> GetAssembly(Type type)
{
var assembly = type.GetTypeInfo().Assembly;
string path = null;
@@ -513,7 +489,7 @@ namespace Emby.Server.Implementations
/// <summary>
/// Creates the instance safe.
/// </summary>
- /// <param name="type">The type.</param>
+ /// <param name="typeInfo">The type information.</param>
/// <returns>System.Object.</returns>
protected object CreateInstanceSafe(Tuple<Type, string> typeInfo)
{
@@ -1004,13 +980,7 @@ namespace Emby.Server.Implementations
return s => JsvReader.GetParseFn(propertyType)(s);
}
- public virtual string PackageRuntime
- {
- get
- {
- return "netcore";
- }
- }
+ public virtual string PackageRuntime => "netcore";
public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths, EnvironmentInfo.EnvironmentInfo environmentInfo)
{
@@ -1049,7 +1019,7 @@ namespace Emby.Server.Implementations
return name + "/" + ApplicationVersion;
}
- private string FormatAttribute(string str)
+ private static string FormatAttribute(string str)
{
var arr = str.ToCharArray();
@@ -1066,13 +1036,7 @@ namespace Emby.Server.Implementations
return result;
}
- protected virtual bool SupportsDualModeSockets
- {
- get
- {
- return true;
- }
- }
+ protected virtual bool SupportsDualModeSockets => true;
private X509Certificate GetCertificate(CertificateInfo info)
{
@@ -1927,18 +1891,9 @@ namespace Emby.Server.Implementations
};
}
- public bool EnableHttps
- {
- get
- {
- return SupportsHttps && ServerConfigurationManager.Configuration.EnableHttps;
- }
- }
+ public bool EnableHttps => SupportsHttps && ServerConfigurationManager.Configuration.EnableHttps;
- public bool SupportsHttps
- {
- get { return Certificate != null || ServerConfigurationManager.Configuration.IsBehindProxy; }
- }
+ public bool SupportsHttps => Certificate != null || ServerConfigurationManager.Configuration.IsBehindProxy;
public async Task<string> GetLocalApiUrl(CancellationToken cancellationToken)
{
@@ -2132,15 +2087,10 @@ namespace Emby.Server.Implementations
}
}
- public string FriendlyName
- {
- get
- {
- return string.IsNullOrEmpty(ServerConfigurationManager.Configuration.ServerName)
- ? Environment.MachineName
- : ServerConfigurationManager.Configuration.ServerName;
- }
- }
+ public string FriendlyName =>
+ string.IsNullOrEmpty(ServerConfigurationManager.Configuration.ServerName)
+ ? Environment.MachineName
+ : ServerConfigurationManager.Configuration.ServerName;
public int HttpPort { get; private set; }
@@ -2177,7 +2127,7 @@ namespace Emby.Server.Implementations
private bool _hasUpdateAvailable;
public bool HasUpdateAvailable
{
- get { return _hasUpdateAvailable; }
+ get => _hasUpdateAvailable;
set
{
var fireEvent = value && !_hasUpdateAvailable;
diff --git a/Emby.Server.Implementations/Channels/ChannelImageProvider.cs b/Emby.Server.Implementations/Channels/ChannelImageProvider.cs
index a6643e83c..7eded70c0 100644
--- a/Emby.Server.Implementations/Channels/ChannelImageProvider.cs
+++ b/Emby.Server.Implementations/Channels/ChannelImageProvider.cs
@@ -30,10 +30,7 @@ namespace Emby.Server.Implementations.Channels
return channel.GetChannelImage(type, cancellationToken);
}
- public string Name
- {
- get { return "Channel Image Provider"; }
- }
+ public string Name => "Channel Image Provider";
public bool Supports(BaseItem item)
{
diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs
index c2160d338..8924d57ee 100644
--- a/Emby.Server.Implementations/Channels/ChannelManager.cs
+++ b/Emby.Server.Implementations/Channels/ChannelManager.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Common.Extensions;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Configuration;
@@ -67,13 +67,7 @@ namespace Emby.Server.Implementations.Channels
_providerManager = providerManager;
}
- private TimeSpan CacheLength
- {
- get
- {
- return TimeSpan.FromHours(3);
- }
- }
+ private static TimeSpan CacheLength => TimeSpan.FromHours(3);
public void AddParts(IEnumerable<IChannel> channels)
{
@@ -269,6 +263,7 @@ namespace Emby.Server.Implementations.Channels
{
};
+ //TODO Fix The co-variant conversion (internalResult.Items) between Folder[] and BaseItem[], this can generate runtime issues.
var returnItems = _dtoService.GetBaseItemDtos(internalResult.Items, dtoOptions, user);
var result = new QueryResult<BaseItemDto>
@@ -419,7 +414,7 @@ namespace Emby.Server.Implementations.Channels
return list;
}
- private MediaSourceInfo NormalizeMediaSource(BaseItem item, MediaSourceInfo info)
+ private static MediaSourceInfo NormalizeMediaSource(BaseItem item, MediaSourceInfo info)
{
info.RunTimeTicks = info.RunTimeTicks ?? item.RunTimeTicks;
@@ -492,7 +487,7 @@ namespace Emby.Server.Implementations.Channels
return item;
}
- private string GetOfficialRating(ChannelParentalRating rating)
+ private static string GetOfficialRating(ChannelParentalRating rating)
{
switch (rating)
{
@@ -533,7 +528,7 @@ namespace Emby.Server.Implementations.Channels
{
if (string.IsNullOrEmpty(id))
{
- throw new ArgumentNullException("id");
+ throw new ArgumentNullException(nameof(id));
}
var channel = GetChannel(id);
@@ -577,7 +572,7 @@ namespace Emby.Server.Implementations.Channels
{
if (string.IsNullOrEmpty(name))
{
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
}
return _libraryManager.GetNewItemId("Channel " + name, typeof(Channel));
}
@@ -891,7 +886,7 @@ namespace Emby.Server.Implementations.Channels
filename + ".json");
}
- private string GetIdToHash(string externalId, string channelName)
+ private static string GetIdToHash(string externalId, string channelName)
{
// Increment this as needed to force new downloads
// Incorporate Name because it's being used to convert channel entity to provider
@@ -1187,7 +1182,7 @@ namespace Emby.Server.Implementations.Channels
{
if (channel == null)
{
- throw new ArgumentNullException("channel");
+ throw new ArgumentNullException(nameof(channel));
}
var result = GetAllChannels()
diff --git a/Emby.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs b/Emby.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs
index ab6acf3c5..1e7818630 100644
--- a/Emby.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs
+++ b/Emby.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs
@@ -25,35 +25,17 @@ namespace Emby.Server.Implementations.Channels
_libraryManager = libraryManager;
}
- public string Name
- {
- get { return "Refresh Channels"; }
- }
+ public string Name => "Refresh Channels";
- public string Description
- {
- get { return "Refreshes internet channel information."; }
- }
+ public string Description => "Refreshes internet channel information.";
- public string Category
- {
- get { return "Internet Channels"; }
- }
+ public string Category => "Internet Channels";
- public bool IsHidden
- {
- get { return ((ChannelManager)_channelManager).Channels.Length == 0; }
- }
+ public bool IsHidden => ((ChannelManager)_channelManager).Channels.Length == 0;
- public bool IsEnabled
- {
- get { return true; }
- }
+ public bool IsEnabled => true;
- public bool IsLogged
- {
- get { return true; }
- }
+ public bool IsLogged => true;
public async Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
{
@@ -77,9 +59,6 @@ namespace Emby.Server.Implementations.Channels
};
}
- public string Key
- {
- get { return "RefreshInternetChannels"; }
- }
+ public string Key => "RefreshInternetChannels";
}
}
diff --git a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
index 015421197..6180645e4 100644
--- a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
+++ b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
@@ -38,28 +38,19 @@ namespace Emby.Server.Implementations.Configuration
/// Gets the type of the configuration.
/// </summary>
/// <value>The type of the configuration.</value>
- protected override Type ConfigurationType
- {
- get { return typeof(ServerConfiguration); }
- }
+ protected override Type ConfigurationType => typeof(ServerConfiguration);
/// <summary>
/// Gets the application paths.
/// </summary>
/// <value>The application paths.</value>
- public IServerApplicationPaths ApplicationPaths
- {
- get { return (IServerApplicationPaths)CommonApplicationPaths; }
- }
+ public IServerApplicationPaths ApplicationPaths => (IServerApplicationPaths)CommonApplicationPaths;
/// <summary>
/// Gets the configuration.
/// </summary>
/// <value>The configuration.</value>
- public ServerConfiguration Configuration
- {
- get { return (ServerConfiguration)CommonConfiguration; }
- }
+ public ServerConfiguration Configuration => (ServerConfiguration)CommonConfiguration;
/// <summary>
/// Called when [configuration updated].
diff --git a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs b/Emby.Server.Implementations/Data/BaseSqliteRepository.cs
index 59776c373..c714ba91b 100644
--- a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs
+++ b/Emby.Server.Implementations/Data/BaseSqliteRepository.cs
@@ -24,15 +24,9 @@ namespace Emby.Server.Implementations.Data
WriteLock = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion);
}
- protected TransactionMode TransactionMode
- {
- get { return TransactionMode.Deferred; }
- }
+ protected TransactionMode TransactionMode => TransactionMode.Deferred;
- protected TransactionMode ReadTransactionMode
- {
- get { return TransactionMode.Deferred; }
- }
+ protected TransactionMode ReadTransactionMode => TransactionMode.Deferred;
internal static int ThreadSafeMode { get; set; }
@@ -58,10 +52,7 @@ namespace Emby.Server.Implementations.Data
private string _defaultWal;
protected ManagedConnection _connection;
- protected virtual bool EnableSingleConnection
- {
- get { return true; }
- }
+ protected virtual bool EnableSingleConnection => true;
protected ManagedConnection CreateConnection(bool isReadOnly = false)
{
@@ -238,21 +229,9 @@ namespace Emby.Server.Implementations.Data
Logger.LogInformation("PRAGMA synchronous=" + db.Query("PRAGMA synchronous").SelectScalarString().First());
}
- protected virtual bool EnableTempStoreMemory
- {
- get
- {
- return false;
- }
- }
+ protected virtual bool EnableTempStoreMemory => false;
- protected virtual int? CacheSize
- {
- get
- {
- return null;
- }
- }
+ protected virtual int? CacheSize => null;
internal static void CheckOk(int rc)
{
@@ -276,7 +255,7 @@ namespace Emby.Server.Implementations.Data
{
if (_disposed)
{
- throw new ObjectDisposedException(GetType().Name + " has been disposed and cannot be accessed.");
+ throw new ObjectDisposedException(GetType().Name ,"Object has been disposed and cannot be accessed.");
}
}
diff --git a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs
index 00e1956cf..49d8f79a2 100644
--- a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs
@@ -32,13 +32,7 @@ namespace Emby.Server.Implementations.Data
/// Gets the name of the repository
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get
- {
- return "SQLite";
- }
- }
+ public string Name => "SQLite";
/// <summary>
/// The _json serializer
@@ -94,11 +88,11 @@ namespace Emby.Server.Implementations.Data
{
if (displayPreferences == null)
{
- throw new ArgumentNullException("displayPreferences");
+ throw new ArgumentNullException(nameof(displayPreferences));
}
if (string.IsNullOrEmpty(displayPreferences.Id))
{
- throw new ArgumentNullException("displayPreferences.Id");
+ throw new ArgumentNullException(nameof(displayPreferences.Id));
}
cancellationToken.ThrowIfCancellationRequested();
@@ -142,7 +136,7 @@ namespace Emby.Server.Implementations.Data
{
if (displayPreferences == null)
{
- throw new ArgumentNullException("displayPreferences");
+ throw new ArgumentNullException(nameof(displayPreferences));
}
cancellationToken.ThrowIfCancellationRequested();
@@ -174,7 +168,7 @@ namespace Emby.Server.Implementations.Data
{
if (string.IsNullOrEmpty(displayPreferencesId))
{
- throw new ArgumentNullException("displayPreferencesId");
+ throw new ArgumentNullException(nameof(displayPreferencesId));
}
var guidId = displayPreferencesId.GetMD5();
diff --git a/Emby.Server.Implementations/Data/SqliteExtensions.cs b/Emby.Server.Implementations/Data/SqliteExtensions.cs
index a755c65f4..d9b2db56e 100644
--- a/Emby.Server.Implementations/Data/SqliteExtensions.cs
+++ b/Emby.Server.Implementations/Data/SqliteExtensions.cs
@@ -14,7 +14,7 @@ namespace Emby.Server.Implementations.Data
{
if (queries == null)
{
- throw new ArgumentNullException("queries");
+ throw new ArgumentNullException(nameof(queries));
}
connection.RunInTransaction(conn =>
@@ -134,7 +134,7 @@ namespace Emby.Server.Implementations.Data
{
if (obj == null)
{
- throw new ArgumentNullException("obj");
+ throw new ArgumentNullException(nameof(obj));
}
using (var stream = new MemoryStream())
diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
index 0f9770e8f..96b650ee0 100644
--- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
@@ -82,11 +82,11 @@ namespace Emby.Server.Implementations.Data
{
if (config == null)
{
- throw new ArgumentNullException("config");
+ throw new ArgumentNullException(nameof(config));
}
if (jsonSerializer == null)
{
- throw new ArgumentNullException("jsonSerializer");
+ throw new ArgumentNullException(nameof(jsonSerializer));
}
_appHost = appHost;
@@ -455,7 +455,7 @@ namespace Emby.Server.Implementations.Data
"ColorTransfer"
};
- private string GetSaveItemCommandText()
+ private static string GetSaveItemCommandText()
{
var saveColumns = new List<string>
{
@@ -558,7 +558,7 @@ namespace Emby.Server.Implementations.Data
{
if (item == null)
{
- throw new ArgumentNullException("item");
+ throw new ArgumentNullException(nameof(item));
}
SaveItems(new List<BaseItem> { item }, cancellationToken);
@@ -568,7 +568,7 @@ namespace Emby.Server.Implementations.Data
{
if (item == null)
{
- throw new ArgumentNullException("item");
+ throw new ArgumentNullException(nameof(item));
}
CheckDisposed();
@@ -605,7 +605,7 @@ namespace Emby.Server.Implementations.Data
{
if (items == null)
{
- throw new ArgumentNullException("items");
+ throw new ArgumentNullException(nameof(items));
}
cancellationToken.ThrowIfCancellationRequested();
@@ -1070,7 +1070,7 @@ namespace Emby.Server.Implementations.Data
saveItemStatement.MoveNext();
}
- private string SerializeProviderIds(BaseItem item)
+ private static string SerializeProviderIds(BaseItem item)
{
// Ideally we shouldn't need this IsNullOrWhiteSpace check but we're seeing some cases of bad data slip through
var ids = item.ProviderIds
@@ -1085,7 +1085,7 @@ namespace Emby.Server.Implementations.Data
return string.Join("|", ids.Select(i => i.Key + "=" + i.Value).ToArray());
}
- private void DeserializeProviderIds(string value, BaseItem item)
+ private static void DeserializeProviderIds(string value, BaseItem item)
{
if (string.IsNullOrWhiteSpace(value))
{
@@ -1226,7 +1226,7 @@ namespace Emby.Server.Implementations.Data
{
if (id.Equals(Guid.Empty))
{
- throw new ArgumentNullException("id");
+ throw new ArgumentNullException(nameof(id));
}
CheckDisposed();
@@ -1948,7 +1948,7 @@ namespace Emby.Server.Implementations.Data
return item;
}
- private Guid[] SplitToGuids(string value)
+ private static Guid[] SplitToGuids(string value)
{
var ids = value.Split('|');
@@ -1965,7 +1965,7 @@ namespace Emby.Server.Implementations.Data
/// <summary>
/// Gets chapters for an item
/// </summary>
- /// <param name="id">The id.</param>
+ /// <param name="item">The item.</param>
/// <returns>IEnumerable{ChapterInfo}.</returns>
/// <exception cref="System.ArgumentNullException">id</exception>
public List<ChapterInfo> GetChapters(BaseItem item)
@@ -1996,7 +1996,7 @@ namespace Emby.Server.Implementations.Data
/// <summary>
/// Gets a single chapter for an item
/// </summary>
- /// <param name="id">The id.</param>
+ /// <param name="item">The item.</param>
/// <param name="index">The index.</param>
/// <returns>ChapterInfo.</returns>
/// <exception cref="System.ArgumentNullException">id</exception>
@@ -2067,12 +2067,12 @@ namespace Emby.Server.Implementations.Data
if (id.Equals(Guid.Empty))
{
- throw new ArgumentNullException("id");
+ throw new ArgumentNullException(nameof(id));
}
if (chapters == null)
{
- throw new ArgumentNullException("chapters");
+ throw new ArgumentNullException(nameof(chapters));
}
using (WriteLock.Write())
@@ -2144,7 +2144,7 @@ namespace Emby.Server.Implementations.Data
}
}
- private bool EnableJoinUserData(InternalItemsQuery query)
+ private static bool EnableJoinUserData(InternalItemsQuery query)
{
if (query.User == null)
{
@@ -2681,7 +2681,7 @@ namespace Emby.Server.Implementations.Data
{
if (query == null)
{
- throw new ArgumentNullException("query");
+ throw new ArgumentNullException(nameof(query));
}
CheckDisposed();
@@ -2739,7 +2739,7 @@ namespace Emby.Server.Implementations.Data
{
if (query == null)
{
- throw new ArgumentNullException("query");
+ throw new ArgumentNullException(nameof(query));
}
CheckDisposed();
@@ -2928,7 +2928,7 @@ namespace Emby.Server.Implementations.Data
{
if (query == null)
{
- throw new ArgumentNullException("query");
+ throw new ArgumentNullException(nameof(query));
}
CheckDisposed();
@@ -3212,7 +3212,7 @@ namespace Emby.Server.Implementations.Data
{
if (query == null)
{
- throw new ArgumentNullException("query");
+ throw new ArgumentNullException(nameof(query));
}
CheckDisposed();
@@ -3286,7 +3286,7 @@ namespace Emby.Server.Implementations.Data
{
if (query == null)
{
- throw new ArgumentNullException("query");
+ throw new ArgumentNullException(nameof(query));
}
CheckDisposed();
@@ -3362,7 +3362,7 @@ namespace Emby.Server.Implementations.Data
{
if (query == null)
{
- throw new ArgumentNullException("query");
+ throw new ArgumentNullException(nameof(query));
}
CheckDisposed();
@@ -5184,7 +5184,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
{
if (id.Equals(Guid.Empty))
{
- throw new ArgumentNullException("id");
+ throw new ArgumentNullException(nameof(id));
}
CheckDisposed();
@@ -5233,7 +5233,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
{
if (query == null)
{
- throw new ArgumentNullException("query");
+ throw new ArgumentNullException(nameof(query));
}
CheckDisposed();
@@ -5273,7 +5273,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
{
if (query == null)
{
- throw new ArgumentNullException("query");
+ throw new ArgumentNullException(nameof(query));
}
CheckDisposed();
@@ -5387,12 +5387,12 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
{
if (itemId.Equals(Guid.Empty))
{
- throw new ArgumentNullException("itemId");
+ throw new ArgumentNullException(nameof(itemId));
}
if (ancestorIds == null)
{
- throw new ArgumentNullException("ancestorIds");
+ throw new ArgumentNullException(nameof(ancestorIds));
}
CheckDisposed();
@@ -5556,7 +5556,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
{
if (query == null)
{
- throw new ArgumentNullException("query");
+ throw new ArgumentNullException(nameof(query));
}
if (!query.Limit.HasValue)
@@ -5915,12 +5915,12 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
{
if (itemId.Equals(Guid.Empty))
{
- throw new ArgumentNullException("itemId");
+ throw new ArgumentNullException(nameof(itemId));
}
if (values == null)
{
- throw new ArgumentNullException("keys");
+ throw new ArgumentNullException(nameof(values));
}
CheckDisposed();
@@ -5991,12 +5991,12 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
{
if (itemId.Equals(Guid.Empty))
{
- throw new ArgumentNullException("itemId");
+ throw new ArgumentNullException(nameof(itemId));
}
if (people == null)
{
- throw new ArgumentNullException("people");
+ throw new ArgumentNullException(nameof(people));
}
CheckDisposed();
@@ -6102,7 +6102,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
if (query == null)
{
- throw new ArgumentNullException("query");
+ throw new ArgumentNullException(nameof(query));
}
var cmdText = "select " + string.Join(",", _mediaStreamSaveColumns) + " from mediastreams where";
@@ -6158,12 +6158,12 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
if (id.Equals(Guid.Empty))
{
- throw new ArgumentNullException("id");
+ throw new ArgumentNullException(nameof(id));
}
if (streams == null)
{
- throw new ArgumentNullException("streams");
+ throw new ArgumentNullException(nameof(streams));
}
cancellationToken.ThrowIfCancellationRequested();
diff --git a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
index 6d4ddcedd..cf60b71d6 100644
--- a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -28,13 +28,7 @@ namespace Emby.Server.Implementations.Data
/// Gets the name of the repository
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get
- {
- return "SQLite";
- }
- }
+ public string Name => "SQLite";
/// <summary>
/// Opens the connection to the database
@@ -136,13 +130,7 @@ namespace Emby.Server.Implementations.Data
return list;
}
- protected override bool EnableTempStoreMemory
- {
- get
- {
- return true;
- }
- }
+ protected override bool EnableTempStoreMemory => true;
/// <summary>
/// Saves the user data.
@@ -151,15 +139,15 @@ namespace Emby.Server.Implementations.Data
{
if (userData == null)
{
- throw new ArgumentNullException("userData");
+ throw new ArgumentNullException(nameof(userData));
}
if (internalUserId <= 0)
{
- throw new ArgumentNullException("internalUserId");
+ throw new ArgumentNullException(nameof(internalUserId));
}
if (string.IsNullOrEmpty(key))
{
- throw new ArgumentNullException("key");
+ throw new ArgumentNullException(nameof(key));
}
PersistUserData(internalUserId, key, userData, cancellationToken);
@@ -169,11 +157,11 @@ namespace Emby.Server.Implementations.Data
{
if (userData == null)
{
- throw new ArgumentNullException("userData");
+ throw new ArgumentNullException(nameof(userData));
}
if (internalUserId <= 0)
{
- throw new ArgumentNullException("internalUserId");
+ throw new ArgumentNullException(nameof(internalUserId));
}
PersistAllUserData(internalUserId, userData, cancellationToken);
@@ -182,7 +170,7 @@ namespace Emby.Server.Implementations.Data
/// <summary>
/// Persists the user data.
/// </summary>
- /// <param name="userId">The user id.</param>
+ /// <param name="internalUserId">The user id.</param>
/// <param name="key">The key.</param>
/// <param name="userData">The user data.</param>
/// <param name="cancellationToken">The cancellation token.</param>
@@ -203,7 +191,7 @@ namespace Emby.Server.Implementations.Data
}
}
- private void SaveUserData(IDatabaseConnection db, long internalUserId, string key, UserItemData userData)
+ private static void SaveUserData(IDatabaseConnection db, long internalUserId, string key, UserItemData userData)
{
using (var statement = db.PrepareStatement("replace into UserDatas (key, userId, rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex) values (@key, @userId, @rating,@played,@playCount,@isFavorite,@playbackPositionTicks,@lastPlayedDate,@AudioStreamIndex,@SubtitleStreamIndex)"))
{
@@ -280,7 +268,7 @@ namespace Emby.Server.Implementations.Data
/// <summary>
/// Gets the user data.
/// </summary>
- /// <param name="userId">The user id.</param>
+ /// <param name="internalUserId">The user id.</param>
/// <param name="key">The key.</param>
/// <returns>Task{UserItemData}.</returns>
/// <exception cref="System.ArgumentNullException">
@@ -292,11 +280,11 @@ namespace Emby.Server.Implementations.Data
{
if (internalUserId <= 0)
{
- throw new ArgumentNullException("internalUserId");
+ throw new ArgumentNullException(nameof(internalUserId));
}
if (string.IsNullOrEmpty(key))
{
- throw new ArgumentNullException("key");
+ throw new ArgumentNullException(nameof(key));
}
using (WriteLock.Read())
@@ -323,7 +311,7 @@ namespace Emby.Server.Implementations.Data
{
if (keys == null)
{
- throw new ArgumentNullException("keys");
+ throw new ArgumentNullException(nameof(keys));
}
if (keys.Count == 0)
@@ -337,13 +325,13 @@ namespace Emby.Server.Implementations.Data
/// <summary>
/// Return all user-data associated with the given user
/// </summary>
- /// <param name="userId"></param>
+ /// <param name="internalUserId"></param>
/// <returns></returns>
public List<UserItemData> GetAllUserData(long internalUserId)
{
if (internalUserId <= 0)
{
- throw new ArgumentNullException("internalUserId");
+ throw new ArgumentNullException(nameof(internalUserId));
}
var list = new List<UserItemData>();
diff --git a/Emby.Server.Implementations/Data/SqliteUserRepository.cs b/Emby.Server.Implementations/Data/SqliteUserRepository.cs
index d490a481e..125f254c1 100644
--- a/Emby.Server.Implementations/Data/SqliteUserRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteUserRepository.cs
@@ -31,13 +31,7 @@ namespace Emby.Server.Implementations.Data
/// Gets the name of the repository
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get
- {
- return "SQLite";
- }
- }
+ public string Name => "SQLite";
/// <summary>
/// Opens the connection to the database
@@ -85,7 +79,7 @@ namespace Emby.Server.Implementations.Data
{
if (user == null)
{
- throw new ArgumentNullException("user");
+ throw new ArgumentNullException(nameof(user));
}
var serialized = _jsonSerializer.SerializeToBytes(user);
@@ -122,7 +116,7 @@ namespace Emby.Server.Implementations.Data
{
if (user == null)
{
- throw new ArgumentNullException("user");
+ throw new ArgumentNullException(nameof(user));
}
var serialized = _jsonSerializer.SerializeToBytes(user);
@@ -207,14 +201,13 @@ namespace Emby.Server.Implementations.Data
/// Deletes the user.
/// </summary>
/// <param name="user">The user.</param>
- /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">user</exception>
public void DeleteUser(User user)
{
if (user == null)
{
- throw new ArgumentNullException("user");
+ throw new ArgumentNullException(nameof(user));
}
using (WriteLock.Write())
diff --git a/Emby.Server.Implementations/Data/TypeMapper.cs b/Emby.Server.Implementations/Data/TypeMapper.cs
index f4b37749e..e0c2de918 100644
--- a/Emby.Server.Implementations/Data/TypeMapper.cs
+++ b/Emby.Server.Implementations/Data/TypeMapper.cs
@@ -32,7 +32,7 @@ namespace Emby.Server.Implementations.Data
{
if (string.IsNullOrEmpty(typeName))
{
- throw new ArgumentNullException("typeName");
+ throw new ArgumentNullException(nameof(typeName));
}
return _typeMap.GetOrAdd(typeName, LookupType);
diff --git a/Emby.Server.Implementations/Devices/DeviceId.cs b/Emby.Server.Implementations/Devices/DeviceId.cs
index 90cef5d06..d85e5c296 100644
--- a/Emby.Server.Implementations/Devices/DeviceId.cs
+++ b/Emby.Server.Implementations/Devices/DeviceId.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.IO;
using System.Text;
using MediaBrowser.Common.Configuration;
@@ -15,10 +15,7 @@ namespace Emby.Server.Implementations.Devices
private readonly object _syncLock = new object();
- private string CachePath
- {
- get { return Path.Combine(_appPaths.DataPath, "device.txt"); }
- }
+ private string CachePath => Path.Combine(_appPaths.DataPath, "device.txt");
private string GetCachedId()
{
@@ -70,7 +67,7 @@ namespace Emby.Server.Implementations.Devices
}
}
- private string GetNewId()
+ private static string GetNewId()
{
return Guid.NewGuid().ToString("N");
}
@@ -93,7 +90,7 @@ namespace Emby.Server.Implementations.Devices
public DeviceId(IApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem)
{
if (fileSystem == null) {
- throw new ArgumentNullException ("fileSystem");
+ throw new ArgumentNullException(nameof(fileSystem));
}
_appPaths = appPaths;
@@ -101,9 +98,6 @@ namespace Emby.Server.Implementations.Devices
_fileSystem = fileSystem;
}
- public string Value
- {
- get { return _id ?? (_id = GetDeviceId()); }
- }
+ public string Value => _id ?? (_id = GetDeviceId());
}
}
diff --git a/Emby.Server.Implementations/Devices/DeviceManager.cs b/Emby.Server.Implementations/Devices/DeviceManager.cs
index f5314df6e..0b15daac9 100644
--- a/Emby.Server.Implementations/Devices/DeviceManager.cs
+++ b/Emby.Server.Implementations/Devices/DeviceManager.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Library;
@@ -360,10 +360,7 @@ namespace Emby.Server.Implementations.Devices
return path;
}
- private string DefaultCameraUploadsPath
- {
- get { return Path.Combine(_config.CommonApplicationPaths.DataPath, "camerauploads"); }
- }
+ private string DefaultCameraUploadsPath => Path.Combine(_config.CommonApplicationPaths.DataPath, "camerauploads");
public bool CanAccessDevice(User user, string deviceId)
{
@@ -373,7 +370,7 @@ namespace Emby.Server.Implementations.Devices
}
if (string.IsNullOrEmpty(deviceId))
{
- throw new ArgumentNullException("deviceId");
+ throw new ArgumentNullException(nameof(deviceId));
}
if (!CanAccessDevice(user.Policy, deviceId))
@@ -389,7 +386,7 @@ namespace Emby.Server.Implementations.Devices
return true;
}
- private bool CanAccessDevice(UserPolicy policy, string id)
+ private static bool CanAccessDevice(UserPolicy policy, string id)
{
if (policy.EnableAllDevices)
{
diff --git a/Emby.Server.Implementations/Diagnostics/CommonProcess.cs b/Emby.Server.Implementations/Diagnostics/CommonProcess.cs
index a709607bd..99871a3c6 100644
--- a/Emby.Server.Implementations/Diagnostics/CommonProcess.cs
+++ b/Emby.Server.Implementations/Diagnostics/CommonProcess.cs
@@ -81,30 +81,15 @@ namespace Emby.Server.Implementations.Diagnostics
}
}
- public ProcessOptions StartInfo
- {
- get { return _options; }
- }
+ public ProcessOptions StartInfo => _options;
- public StreamWriter StandardInput
- {
- get { return _process.StandardInput; }
- }
+ public StreamWriter StandardInput => _process.StandardInput;
- public StreamReader StandardError
- {
- get { return _process.StandardError; }
- }
+ public StreamReader StandardError => _process.StandardError;
- public StreamReader StandardOutput
- {
- get { return _process.StandardOutput; }
- }
+ public StreamReader StandardOutput => _process.StandardOutput;
- public int ExitCode
- {
- get { return _process.ExitCode; }
- }
+ public int ExitCode => _process.ExitCode;
public void Start()
{
diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs
index 7871d3fb3..3d519f35d 100644
--- a/Emby.Server.Implementations/Dto/DtoService.cs
+++ b/Emby.Server.Implementations/Dto/DtoService.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Common;
+using MediaBrowser.Common;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices;
@@ -189,7 +189,7 @@ namespace Emby.Server.Implementations.Dto
return dto;
}
- private IList<BaseItem> GetTaggedItems(IItemByName byName, User user, DtoOptions options)
+ private static IList<BaseItem> GetTaggedItems(IItemByName byName, User user, DtoOptions options)
{
return byName.GetTaggedItems(new InternalItemsQuery(user)
{
@@ -295,7 +295,7 @@ namespace Emby.Server.Implementations.Dto
return dto;
}
- private void NormalizeMediaSourceContainers(BaseItemDto dto)
+ private static void NormalizeMediaSourceContainers(BaseItemDto dto)
{
foreach (var mediaSource in dto.MediaSources)
{
@@ -347,7 +347,7 @@ namespace Emby.Server.Implementations.Dto
return dto;
}
- private void SetItemByNameInfo(BaseItem item, BaseItemDto dto, IList<BaseItem> taggedItems, User user = null)
+ private static void SetItemByNameInfo(BaseItem item, BaseItemDto dto, IList<BaseItem> taggedItems, User user = null)
{
if (item is MusicArtist)
{
@@ -447,7 +447,7 @@ namespace Emby.Server.Implementations.Dto
}
}
- private int GetChildCount(Folder folder, User user)
+ private static int GetChildCount(Folder folder, User user)
{
// Right now this is too slow to calculate for top level folders on a per-user basis
// Just return something so that apps that are expecting a value won't think the folders are empty
@@ -470,11 +470,11 @@ namespace Emby.Server.Implementations.Dto
return item.Id.ToString("N");
}
- private void SetBookProperties(BaseItemDto dto, Book item)
+ private static void SetBookProperties(BaseItemDto dto, Book item)
{
dto.SeriesName = item.SeriesName;
}
- private void SetPhotoProperties(BaseItemDto dto, Photo item)
+ private static void SetPhotoProperties(BaseItemDto dto, Photo item)
{
dto.CameraMake = item.CameraMake;
dto.CameraModel = item.CameraModel;
@@ -520,13 +520,13 @@ namespace Emby.Server.Implementations.Dto
dto.Album = item.Album;
}
- private void SetGameProperties(BaseItemDto dto, Game item)
+ private static void SetGameProperties(BaseItemDto dto, Game item)
{
dto.GameSystem = item.GameSystem;
dto.MultiPartGameFiles = item.MultiPartGameFiles;
}
- private void SetGameSystemProperties(BaseItemDto dto, GameSystem item)
+ private static void SetGameSystemProperties(BaseItemDto dto, GameSystem item)
{
dto.GameSystem = item.GameSystemName;
}
diff --git a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs
index 6cd867921..6c658a695 100644
--- a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs
+++ b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net;
@@ -227,7 +227,7 @@ namespace Emby.Server.Implementations.EntryPoints
{
if (_disposed)
{
- throw new ObjectDisposedException("PortMapper");
+ throw new ObjectDisposedException(GetType().Name);
}
// On some systems the device discovered event seems to fire repeatedly
diff --git a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs
index bb8ef52f1..5958c5a1a 100644
--- a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs
+++ b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Controller.Session;
@@ -142,7 +142,7 @@ namespace Emby.Server.Implementations.EntryPoints
_providerManager_RefreshProgress(sender, new GenericEventArgs<Tuple<BaseItem, double>>(new Tuple<BaseItem, double>(e.Argument, 100)));
}
- private bool EnableRefreshMessage(BaseItem item)
+ private static bool EnableRefreshMessage(BaseItem item)
{
var folder = item as Folder;
@@ -387,7 +387,7 @@ namespace Emby.Server.Implementations.EntryPoints
};
}
- private bool FilterItem(BaseItem item)
+ private static bool FilterItem(BaseItem item)
{
if (!item.IsFolder && !item.HasPathProtocol)
{
diff --git a/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs b/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs
index 0b377dc68..c7bd03960 100644
--- a/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs
+++ b/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Linq;
using System.Threading;
using MediaBrowser.Controller.Library;
@@ -62,7 +62,7 @@ namespace Emby.Server.Implementations.EntryPoints
}
catch (ObjectDisposedException)
{
-
+ // TODO Log exception or Investigate and properly fix.
}
catch (Exception ex)
{
diff --git a/Emby.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs b/Emby.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs
index 660ca3a94..f0b834ccb 100644
--- a/Emby.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs
+++ b/Emby.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs
@@ -30,10 +30,7 @@ namespace Emby.Server.Implementations.EntryPoints
public string Description => "Refresh user infos";
- public string Category
- {
- get { return "Library"; }
- }
+ public string Category => "Library";
public bool IsHidden => true;
diff --git a/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs b/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs
index 655867577..24a3456c4 100644
--- a/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs
+++ b/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs
@@ -29,14 +29,8 @@ namespace Emby.Server.Implementations.EnvironmentInfo
}
}
- public string OperatingSystemVersion
- {
- get
- {
- return Environment.OSVersion.Version.ToString() + " " + Environment.OSVersion.ServicePack.ToString();
- }
- }
+ public string OperatingSystemVersion => Environment.OSVersion.Version.ToString() + " " + Environment.OSVersion.ServicePack.ToString();
- public Architecture SystemArchitecture { get { return RuntimeInformation.OSArchitecture; } }
+ public Architecture SystemArchitecture => RuntimeInformation.OSArchitecture;
}
}
diff --git a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs
index d3ba1b683..6494f0c6f 100644
--- a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs
+++ b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
@@ -48,11 +48,11 @@ namespace Emby.Server.Implementations.HttpClientManager
{
if (appPaths == null)
{
- throw new ArgumentNullException("appPaths");
+ throw new ArgumentNullException(nameof(appPaths));
}
if (logger == null)
{
- throw new ArgumentNullException("logger");
+ throw new ArgumentNullException(nameof(logger));
}
_logger = logger;
@@ -87,7 +87,7 @@ namespace Emby.Server.Implementations.HttpClientManager
{
if (string.IsNullOrEmpty(host))
{
- throw new ArgumentNullException("host");
+ throw new ArgumentNullException(nameof(host));
}
HttpClientInfo client;
@@ -104,7 +104,7 @@ namespace Emby.Server.Implementations.HttpClientManager
return client;
}
- private WebRequest CreateWebRequest(string url)
+ private static WebRequest CreateWebRequest(string url)
{
try
{
@@ -185,7 +185,7 @@ namespace Emby.Server.Implementations.HttpClientManager
return request;
}
- private CredentialCache GetCredential(string url, string username, string password)
+ private static CredentialCache GetCredential(string url, string username, string password)
{
//ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
CredentialCache credentialCache = new CredentialCache();
@@ -220,7 +220,7 @@ namespace Emby.Server.Implementations.HttpClientManager
}
}
- private void SetUserAgent(HttpWebRequest request, string userAgent)
+ private static void SetUserAgent(HttpWebRequest request, string userAgent)
{
request.UserAgent = userAgent;
}
@@ -491,7 +491,7 @@ namespace Emby.Server.Implementations.HttpClientManager
return responseInfo;
}
- private void SetHeaders(WebHeaderCollection headers, HttpResponseInfo responseInfo)
+ private static void SetHeaders(WebHeaderCollection headers, HttpResponseInfo responseInfo)
{
foreach (var key in headers.AllKeys)
{
@@ -541,7 +541,7 @@ namespace Emby.Server.Implementations.HttpClientManager
if (options.Progress == null)
{
- throw new ArgumentNullException("progress");
+ throw new ArgumentException("Options did not have a Progress value.",nameof(options));
}
options.CancellationToken.ThrowIfCancellationRequested();
@@ -616,7 +616,7 @@ namespace Emby.Server.Implementations.HttpClientManager
}
}
- private long? GetContentLength(HttpWebResponse response)
+ private static long? GetContentLength(HttpWebResponse response)
{
var length = response.ContentLength;
@@ -704,7 +704,7 @@ namespace Emby.Server.Implementations.HttpClientManager
{
if (string.IsNullOrEmpty(options.Url))
{
- throw new ArgumentNullException("options");
+ throw new ArgumentNullException(nameof(options));
}
}
@@ -713,7 +713,7 @@ namespace Emby.Server.Implementations.HttpClientManager
/// </summary>
/// <param name="url">The URL.</param>
/// <returns>System.String.</returns>
- private string GetHostFromUrl(string url)
+ private static string GetHostFromUrl(string url)
{
var index = url.IndexOf("://", StringComparison.OrdinalIgnoreCase);
@@ -803,7 +803,7 @@ namespace Emby.Server.Implementations.HttpClientManager
};
}
- private Task<WebResponse> GetResponseAsync(WebRequest request, TimeSpan timeout)
+ private static Task<WebResponse> GetResponseAsync(WebRequest request, TimeSpan timeout)
{
var taskCompletion = new TaskCompletionSource<WebResponse>();
diff --git a/Emby.Server.Implementations/HttpServer/FileWriter.cs b/Emby.Server.Implementations/HttpServer/FileWriter.cs
index 1a875e533..e0e579165 100644
--- a/Emby.Server.Implementations/HttpServer/FileWriter.cs
+++ b/Emby.Server.Implementations/HttpServer/FileWriter.cs
@@ -38,10 +38,7 @@ namespace Emby.Server.Implementations.HttpServer
/// Gets the options.
/// </summary>
/// <value>The options.</value>
- public IDictionary<string, string> Headers
- {
- get { return _options; }
- }
+ public IDictionary<string, string> Headers => _options;
public string Path { get; set; }
@@ -49,7 +46,7 @@ namespace Emby.Server.Implementations.HttpServer
{
if (string.IsNullOrEmpty(contentType))
{
- throw new ArgumentNullException("contentType");
+ throw new ArgumentNullException(nameof(contentType));
}
Path = path;
@@ -203,8 +200,8 @@ namespace Emby.Server.Implementations.HttpServer
public HttpStatusCode StatusCode
{
- get { return (HttpStatusCode)Status; }
- set { Status = (int)value; }
+ get => (HttpStatusCode)Status;
+ set => Status = (int)value;
}
public string StatusDescription { get; set; }
diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
index 69ca0f85b..f5c93a096 100644
--- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
+++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Common.Extensions;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Net;
using Microsoft.Extensions.Logging;
@@ -89,13 +89,7 @@ namespace Emby.Server.Implementations.HttpServer
{typeof (ArgumentException), 400}
};
- protected ILogger Logger
- {
- get
- {
- return _logger;
- }
- }
+ protected ILogger Logger => _logger;
public object CreateInstance(Type type)
{
@@ -190,10 +184,9 @@ namespace Emby.Server.Implementations.HttpServer
}
}
- private Exception GetActualException(Exception ex)
+ private static Exception GetActualException(Exception ex)
{
- var agg = ex as AggregateException;
- if (agg != null)
+ if (ex is AggregateException agg)
{
var inner = agg.InnerException;
if (inner != null)
@@ -346,7 +339,7 @@ namespace Emby.Server.Implementations.HttpServer
return false;
}
- private string GetExtension(string url)
+ private static string GetExtension(string url)
{
var parts = url.Split(new[] { '?' }, 2);
@@ -379,18 +372,18 @@ namespace Emby.Server.Implementations.HttpServer
string pagePathWithoutQueryString = url.Split(new[] { '?' }, StringSplitOptions.RemoveEmptyEntries)[0];
return newQueryString.Count > 0
- ? String.Format("{0}?{1}", pagePathWithoutQueryString, newQueryString)
+ ? string.Format("{0}?{1}", pagePathWithoutQueryString, newQueryString)
: pagePathWithoutQueryString;
}
- private string GetUrlToLog(string url)
+ private static string GetUrlToLog(string url)
{
url = RemoveQueryStringByKey(url, "api_key");
return url;
}
- private string NormalizeConfiguredLocalAddress(string address)
+ private static string NormalizeConfiguredLocalAddress(string address)
{
var index = address.Trim('/').IndexOf('/');
@@ -727,7 +720,7 @@ namespace Emby.Server.Implementations.HttpServer
return null;
}
- private Task Write(IResponse response, string text)
+ private static Task Write(IResponse response, string text)
{
var bOutput = Encoding.UTF8.GetBytes(text);
response.SetContentLength(bOutput.Length);
@@ -853,7 +846,9 @@ namespace Emby.Server.Implementations.HttpServer
return _jsonSerializer.DeserializeFromStreamAsync(stream, type);
}
- private string NormalizeEmbyRoutePath(string path)
+ //TODO Add Jellyfin Route Path Normalizer
+
+ private static string NormalizeEmbyRoutePath(string path)
{
if (path.StartsWith("/", StringComparison.OrdinalIgnoreCase))
{
@@ -863,7 +858,7 @@ namespace Emby.Server.Implementations.HttpServer
return "emby/" + path;
}
- private string NormalizeMediaBrowserRoutePath(string path)
+ private static string NormalizeMediaBrowserRoutePath(string path)
{
if (path.StartsWith("/", StringComparison.OrdinalIgnoreCase))
{
@@ -873,7 +868,7 @@ namespace Emby.Server.Implementations.HttpServer
return "mediabrowser/" + path;
}
- private string DoubleNormalizeEmbyRoutePath(string path)
+ private static string DoubleNormalizeEmbyRoutePath(string path)
{
if (path.StartsWith("/", StringComparison.OrdinalIgnoreCase))
{
diff --git a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs
index 73b2afe64..05ec18642 100644
--- a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs
+++ b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Common.Extensions;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Net;
using Microsoft.Extensions.Logging;
using MediaBrowser.Model.Serialization;
@@ -207,7 +207,7 @@ namespace Emby.Server.Implementations.HttpServer
{
if (result == null)
{
- throw new ArgumentNullException("result");
+ throw new ArgumentNullException(nameof(result));
}
if (responseHeaders == null)
@@ -245,7 +245,7 @@ namespace Emby.Server.Implementations.HttpServer
return GetCompressionType(request);
}
- private string GetCompressionType(IRequest request)
+ private static string GetCompressionType(IRequest request)
{
var acceptEncoding = request.Headers["Accept-Encoding"];
@@ -365,7 +365,7 @@ namespace Emby.Server.Implementations.HttpServer
return _brotliCompressor.Compress(bytes);
}
- private byte[] Deflate(byte[] bytes)
+ private static byte[] Deflate(byte[] bytes)
{
// In .NET FX incompat-ville, you can't access compressed bytes without closing DeflateStream
// Which means we must use MemoryStream since you have to use ToArray() on a closed Stream
@@ -379,7 +379,7 @@ namespace Emby.Server.Implementations.HttpServer
}
}
- private byte[] GZip(byte[] buffer)
+ private static byte[] GZip(byte[] buffer)
{
using (var ms = new MemoryStream())
using (var zipStream = new GZipStream(ms, CompressionMode.Compress))
@@ -398,7 +398,7 @@ namespace Emby.Server.Implementations.HttpServer
: contentType.Split(';')[0].ToLower().Trim();
}
- private string SerializeToXmlString(object from)
+ private static string SerializeToXmlString(object from)
{
using (var ms = new MemoryStream())
{
@@ -453,7 +453,7 @@ namespace Emby.Server.Implementations.HttpServer
{
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
return GetStaticFileResult(requestContext, new StaticFileResultOptions
@@ -471,7 +471,7 @@ namespace Emby.Server.Implementations.HttpServer
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
if (fileShare != FileShareMode.Read && fileShare != FileShareMode.ReadWrite)
@@ -661,7 +661,7 @@ namespace Emby.Server.Implementations.HttpServer
/// <summary>
/// Adds the expires header.
/// </summary>
- private void AddExpiresHeader(IDictionary<string, string> responseHeaders, string cacheKey, TimeSpan? cacheDuration)
+ private static void AddExpiresHeader(IDictionary<string, string> responseHeaders, string cacheKey, TimeSpan? cacheDuration)
{
if (cacheDuration.HasValue)
{
@@ -678,7 +678,7 @@ namespace Emby.Server.Implementations.HttpServer
/// </summary>
/// <param name="responseHeaders">The responseHeaders.</param>
/// <param name="lastDateModified">The last date modified.</param>
- private void AddAgeHeader(IDictionary<string, string> responseHeaders, DateTime? lastDateModified)
+ private static void AddAgeHeader(IDictionary<string, string> responseHeaders, DateTime? lastDateModified)
{
if (lastDateModified.HasValue)
{
@@ -771,7 +771,7 @@ namespace Emby.Server.Implementations.HttpServer
/// </summary>
/// <param name="date">The date.</param>
/// <returns>DateTime.</returns>
- private DateTime NormalizeDateForComparison(DateTime date)
+ private static DateTime NormalizeDateForComparison(DateTime date)
{
return new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, date.Kind);
}
@@ -781,7 +781,7 @@ namespace Emby.Server.Implementations.HttpServer
/// </summary>
/// <param name="hasHeaders">The has options.</param>
/// <param name="responseHeaders">The response headers.</param>
- private void AddResponseHeaders(IHasHeaders hasHeaders, IEnumerable<KeyValuePair<string, string>> responseHeaders)
+ private static void AddResponseHeaders(IHasHeaders hasHeaders, IEnumerable<KeyValuePair<string, string>> responseHeaders)
{
foreach (var item in responseHeaders)
{
diff --git a/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs b/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs
index dc20ee1a2..f08112f9c 100644
--- a/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs
+++ b/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs
@@ -1,4 +1,4 @@
-using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -46,10 +46,7 @@ namespace Emby.Server.Implementations.HttpServer
/// Additional HTTP Headers
/// </summary>
/// <value>The headers.</value>
- public IDictionary<string, string> Headers
- {
- get { return _options; }
- }
+ public IDictionary<string, string> Headers => _options;
/// <summary>
/// Initializes a new instance of the <see cref="StreamWriter" /> class.
@@ -62,7 +59,7 @@ namespace Emby.Server.Implementations.HttpServer
{
if (string.IsNullOrEmpty(contentType))
{
- throw new ArgumentNullException("contentType");
+ throw new ArgumentNullException(nameof(contentType));
}
RangeHeader = rangeHeader;
@@ -186,7 +183,7 @@ namespace Emby.Server.Implementations.HttpServer
}
}
- private async Task CopyToInternalAsync(Stream source, Stream destination, long copyLength)
+ private static async Task CopyToInternalAsync(Stream source, Stream destination, long copyLength)
{
var array = new byte[BufferSize];
int bytesRead;
@@ -220,8 +217,8 @@ namespace Emby.Server.Implementations.HttpServer
public HttpStatusCode StatusCode
{
- get { return (HttpStatusCode)Status; }
- set { Status = (int)value; }
+ get => (HttpStatusCode)Status;
+ set => Status = (int)value;
}
public string StatusDescription { get; set; }
diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs
index e153d6f71..fb5bfa601 100644
--- a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs
+++ b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Connect;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Entities;
@@ -173,7 +173,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
return false;
}
- private void ValidateRoles(string[] roles, User user)
+ private static void ValidateRoles(string[] roles, User user)
{
if (roles.Contains("admin", StringComparer.OrdinalIgnoreCase))
{
@@ -207,7 +207,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
}
}
- private AuthenticationInfo GetTokenInfo(IRequest request)
+ private static AuthenticationInfo GetTokenInfo(IRequest request)
{
object info;
request.Items.TryGetValue("OriginalAuthenticationInfo", out info);
diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs
index c3e2d3170..e632e4d27 100644
--- a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs
+++ b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Controller.Connect;
+using MediaBrowser.Controller.Connect;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Security;
using System;
@@ -227,7 +227,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
return result;
}
- private string NormalizeValue(string value)
+ private static string NormalizeValue(string value)
{
if (string.IsNullOrEmpty(value))
{
diff --git a/Emby.Server.Implementations/HttpServer/StreamWriter.cs b/Emby.Server.Implementations/HttpServer/StreamWriter.cs
index 0a44a5fe5..df0d74685 100644
--- a/Emby.Server.Implementations/HttpServer/StreamWriter.cs
+++ b/Emby.Server.Implementations/HttpServer/StreamWriter.cs
@@ -35,10 +35,7 @@ namespace Emby.Server.Implementations.HttpServer
/// Gets the options.
/// </summary>
/// <value>The options.</value>
- public IDictionary<string, string> Headers
- {
- get { return _options; }
- }
+ public IDictionary<string, string> Headers => _options;
public Action OnComplete { get; set; }
public Action OnError { get; set; }
@@ -53,7 +50,7 @@ namespace Emby.Server.Implementations.HttpServer
{
if (string.IsNullOrEmpty(contentType))
{
- throw new ArgumentNullException("contentType");
+ throw new ArgumentNullException(nameof(contentType));
}
SourceStream = source;
@@ -77,7 +74,7 @@ namespace Emby.Server.Implementations.HttpServer
{
if (string.IsNullOrEmpty(contentType))
{
- throw new ArgumentNullException("contentType");
+ throw new ArgumentNullException(nameof(contentType));
}
SourceBytes = source;
diff --git a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs
index 914fa9dbc..5426114f6 100644
--- a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs
+++ b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs
@@ -82,19 +82,19 @@ namespace Emby.Server.Implementations.HttpServer
{
if (socket == null)
{
- throw new ArgumentNullException("socket");
+ throw new ArgumentNullException(nameof(socket));
}
if (string.IsNullOrEmpty(remoteEndPoint))
{
- throw new ArgumentNullException("remoteEndPoint");
+ throw new ArgumentNullException(nameof(remoteEndPoint));
}
if (jsonSerializer == null)
{
- throw new ArgumentNullException("jsonSerializer");
+ throw new ArgumentNullException(nameof(jsonSerializer));
}
if (logger == null)
{
- throw new ArgumentNullException("logger");
+ throw new ArgumentNullException(nameof(logger));
}
Id = Guid.NewGuid();
@@ -148,7 +148,8 @@ namespace Emby.Server.Implementations.HttpServer
/// <summary>
/// Called when [receive].
/// </summary>
- /// <param name="bytes">The bytes.</param>
+ /// <param name="memory">The memory block.</param>
+ /// <param name="length">The length of the memory block.</param>
private void OnReceiveInternal(Memory<byte> memory, int length)
{
LastActivityDate = DateTime.UtcNow;
@@ -219,7 +220,7 @@ namespace Emby.Server.Implementations.HttpServer
{
if (message == null)
{
- throw new ArgumentNullException("message");
+ throw new ArgumentNullException(nameof(message));
}
var json = _jsonSerializer.SerializeToString(message);
@@ -237,7 +238,7 @@ namespace Emby.Server.Implementations.HttpServer
{
if (buffer == null)
{
- throw new ArgumentNullException("buffer");
+ throw new ArgumentNullException(nameof(buffer));
}
cancellationToken.ThrowIfCancellationRequested();
@@ -249,7 +250,7 @@ namespace Emby.Server.Implementations.HttpServer
{
if (string.IsNullOrEmpty(text))
{
- throw new ArgumentNullException("text");
+ throw new ArgumentNullException(nameof(text));
}
cancellationToken.ThrowIfCancellationRequested();
@@ -261,10 +262,7 @@ namespace Emby.Server.Implementations.HttpServer
/// Gets the state.
/// </summary>
/// <value>The state.</value>
- public WebSocketState State
- {
- get { return _socket.State; }
- }
+ public WebSocketState State => _socket.State;
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
diff --git a/Emby.Server.Implementations/IO/FileRefresher.cs b/Emby.Server.Implementations/IO/FileRefresher.cs
index 34c711324..56fbf622c 100644
--- a/Emby.Server.Implementations/IO/FileRefresher.cs
+++ b/Emby.Server.Implementations/IO/FileRefresher.cs
@@ -51,7 +51,7 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
if (!_affectedPaths.Contains(path, StringComparer.Ordinal))
@@ -64,7 +64,7 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
lock (_timerLock)
diff --git a/Emby.Server.Implementations/IO/IsoManager.cs b/Emby.Server.Implementations/IO/IsoManager.cs
index 903d5f301..e0cf32868 100644
--- a/Emby.Server.Implementations/IO/IsoManager.cs
+++ b/Emby.Server.Implementations/IO/IsoManager.cs
@@ -29,7 +29,7 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(isoPath))
{
- throw new ArgumentNullException("isoPath");
+ throw new ArgumentNullException(nameof(isoPath));
}
var mounter = _mounters.FirstOrDefault(i => i.CanMount(isoPath));
diff --git a/Emby.Server.Implementations/IO/LibraryMonitor.cs b/Emby.Server.Implementations/IO/LibraryMonitor.cs
index ca5810fd6..9a224bd0e 100644
--- a/Emby.Server.Implementations/IO/LibraryMonitor.cs
+++ b/Emby.Server.Implementations/IO/LibraryMonitor.cs
@@ -77,7 +77,7 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
TemporarilyIgnore(path);
@@ -95,7 +95,7 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
// This is an arbitraty amount of time, but delay it because file system writes often trigger events long after the file was actually written to.
@@ -145,7 +145,7 @@ namespace Emby.Server.Implementations.IO
{
if (taskManager == null)
{
- throw new ArgumentNullException("taskManager");
+ throw new ArgumentNullException(nameof(taskManager));
}
LibraryManager = libraryManager;
@@ -268,7 +268,7 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
path = path.TrimEnd(Path.DirectorySeparatorChar);
@@ -469,7 +469,7 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
var filename = Path.GetFileName(path);
diff --git a/Emby.Server.Implementations/IO/ManagedFileSystem.cs b/Emby.Server.Implementations/IO/ManagedFileSystem.cs
index 0f85e0642..5a5523a56 100644
--- a/Emby.Server.Implementations/IO/ManagedFileSystem.cs
+++ b/Emby.Server.Implementations/IO/ManagedFileSystem.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@@ -85,17 +85,11 @@ namespace Emby.Server.Implementations.IO
{
// Be consistent across platforms because the windows server will fail to query network shares that don't follow windows conventions
// https://referencesource.microsoft.com/#mscorlib/system/io/path.cs
- _invalidFileNameChars = new char[] { '\"', '<', '>', '|', '\0', (Char)1, (Char)2, (Char)3, (Char)4, (Char)5, (Char)6, (Char)7, (Char)8, (Char)9, (Char)10, (Char)11, (Char)12, (Char)13, (Char)14, (Char)15, (Char)16, (Char)17, (Char)18, (Char)19, (Char)20, (Char)21, (Char)22, (Char)23, (Char)24, (Char)25, (Char)26, (Char)27, (Char)28, (Char)29, (Char)30, (Char)31, ':', '*', '?', '\\', '/' };
+ _invalidFileNameChars = new char[] { '\"', '<', '>', '|', '\0', (char)1, (char)2, (char)3, (char)4, (char)5, (char)6, (char)7, (char)8, (char)9, (char)10, (char)11, (char)12, (char)13, (char)14, (char)15, (char)16, (char)17, (char)18, (char)19, (char)20, (char)21, (char)22, (char)23, (char)24, (char)25, (char)26, (char)27, (char)28, (char)29, (char)30, (char)31, ':', '*', '?', '\\', '/' };
}
}
- public char DirectorySeparatorChar
- {
- get
- {
- return Path.DirectorySeparatorChar;
- }
- }
+ public char DirectorySeparatorChar => Path.DirectorySeparatorChar;
public string GetFullPath(string path)
{
@@ -112,7 +106,7 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(filename))
{
- throw new ArgumentNullException("filename");
+ throw new ArgumentNullException(nameof(filename));
}
var extension = Path.GetExtension(filename);
@@ -129,7 +123,7 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(filename))
{
- throw new ArgumentNullException("filename");
+ throw new ArgumentNullException(nameof(filename));
}
var extension = Path.GetExtension(filename);
@@ -145,7 +139,7 @@ namespace Emby.Server.Implementations.IO
public string MakeAbsolutePath(string folderPath, string filePath)
{
- if (String.IsNullOrWhiteSpace(filePath)) return filePath;
+ if (string.IsNullOrWhiteSpace(filePath)) return filePath;
if (filePath.Contains(@"://")) return filePath; //stream
if (filePath.Length > 3 && filePath[1] == ':' && filePath[2] == '/') return filePath; //absolute local path
@@ -200,12 +194,12 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(shortcutPath))
{
- throw new ArgumentNullException("shortcutPath");
+ throw new ArgumentNullException(nameof(shortcutPath));
}
if (string.IsNullOrEmpty(target))
{
- throw new ArgumentNullException("target");
+ throw new ArgumentNullException(nameof(target));
}
var extension = Path.GetExtension(shortcutPath);
@@ -321,7 +315,7 @@ namespace Emby.Server.Implementations.IO
return result;
}
- private ExtendedFileSystemInfo GetExtendedFileSystemInfo(string path)
+ private static ExtendedFileSystemInfo GetExtendedFileSystemInfo(string path)
{
var result = new ExtendedFileSystemInfo();
@@ -456,13 +450,13 @@ namespace Emby.Server.Implementations.IO
return new FileStream(path, GetFileMode(mode), GetFileAccess(access), GetFileShare(share), defaultBufferSize, GetFileOptions(fileOpenOptions));
}
- private FileOptions GetFileOptions(FileOpenOptions mode)
+ private static FileOptions GetFileOptions(FileOpenOptions mode)
{
var val = (int)mode;
return (FileOptions)val;
}
- private FileMode GetFileMode(FileOpenMode mode)
+ private static FileMode GetFileMode(FileOpenMode mode)
{
switch (mode)
{
@@ -483,7 +477,7 @@ namespace Emby.Server.Implementations.IO
}
}
- private FileAccess GetFileAccess(FileAccessMode mode)
+ private static FileAccess GetFileAccess(FileAccessMode mode)
{
switch (mode)
{
@@ -498,7 +492,7 @@ namespace Emby.Server.Implementations.IO
}
}
- private FileShare GetFileShare(FileShareMode mode)
+ private static FileShare GetFileShare(FileShareMode mode)
{
switch (mode)
{
@@ -619,12 +613,12 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(file1))
{
- throw new ArgumentNullException("file1");
+ throw new ArgumentNullException(nameof(file1));
}
if (string.IsNullOrEmpty(file2))
{
- throw new ArgumentNullException("file2");
+ throw new ArgumentNullException(nameof(file2));
}
var temp1 = Path.Combine(_tempPath, Guid.NewGuid().ToString("N"));
@@ -640,7 +634,7 @@ namespace Emby.Server.Implementations.IO
CopyFile(temp1, file2, true);
}
- private char GetDirectorySeparatorChar(string path)
+ private static char GetDirectorySeparatorChar(string path)
{
return Path.DirectorySeparatorChar;
}
@@ -649,12 +643,12 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(parentPath))
{
- throw new ArgumentNullException("parentPath");
+ throw new ArgumentNullException(nameof(parentPath));
}
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
var separatorChar = GetDirectorySeparatorChar(parentPath);
@@ -666,7 +660,7 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
var parent = GetDirectoryName(path);
@@ -688,7 +682,7 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
if (path.EndsWith(":\\", StringComparison.OrdinalIgnoreCase))
@@ -772,7 +766,7 @@ namespace Emby.Server.Implementations.IO
}).ToList();
}
- private string GetName(DriveInfo drive)
+ private static string GetName(DriveInfo drive)
{
return drive.Name;
}
@@ -972,7 +966,7 @@ namespace Emby.Server.Implementations.IO
}
}
- private void RunProcess(string path, string args, string workingDirectory)
+ private static void RunProcess(string path, string args, string workingDirectory)
{
using (var process = Process.Start(new ProcessStartInfo
{
diff --git a/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs b/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs
index aef53751e..8ac662f78 100644
--- a/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs
+++ b/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs
@@ -15,16 +15,13 @@ namespace Emby.Server.Implementations.IO
_fileSystem = fileSystem;
}
- public string Extension
- {
- get { return ".mblink"; }
- }
+ public string Extension => ".mblink";
public string Resolve(string shortcutPath)
{
if (string.IsNullOrEmpty(shortcutPath))
{
- throw new ArgumentNullException("filenshortcutPathame");
+ throw new ArgumentException("Shortcut path is empty or null.", nameof(shortcutPath));
}
if (string.Equals(Path.GetExtension(shortcutPath), ".mblink", StringComparison.OrdinalIgnoreCase))
@@ -41,12 +38,12 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(shortcutPath))
{
- throw new ArgumentNullException("shortcutPath");
+ throw new ArgumentNullException(nameof(shortcutPath));
}
if (string.IsNullOrEmpty(targetPath))
{
- throw new ArgumentNullException("targetPath");
+ throw new ArgumentNullException(nameof(targetPath));
}
_fileSystem.WriteAllText(shortcutPath, targetPath);
diff --git a/Emby.Server.Implementations/IO/ThrottledStream.cs b/Emby.Server.Implementations/IO/ThrottledStream.cs
index 81760b639..3635ee1db 100644
--- a/Emby.Server.Implementations/IO/ThrottledStream.cs
+++ b/Emby.Server.Implementations/IO/ThrottledStream.cs
@@ -42,13 +42,7 @@ namespace Emby.Server.Implementations.IO
/// Gets the current milliseconds.
/// </summary>
/// <value>The current milliseconds.</value>
- protected long CurrentMilliseconds
- {
- get
- {
- return Environment.TickCount;
- }
- }
+ protected long CurrentMilliseconds => Environment.TickCount;
/// <summary>
/// Gets or sets the maximum bytes per second that can be transferred through the base stream.
@@ -56,10 +50,7 @@ namespace Emby.Server.Implementations.IO
/// <value>The maximum bytes per second.</value>
public long MaximumBytesPerSecond
{
- get
- {
- return _maximumBytesPerSecond;
- }
+ get => _maximumBytesPerSecond;
set
{
if (MaximumBytesPerSecond != value)
@@ -74,39 +65,21 @@ namespace Emby.Server.Implementations.IO
/// Gets a value indicating whether the current stream supports reading.
/// </summary>
/// <returns>true if the stream supports reading; otherwise, false.</returns>
- public override bool CanRead
- {
- get
- {
- return _baseStream.CanRead;
- }
- }
+ public override bool CanRead => _baseStream.CanRead;
/// <summary>
/// Gets a value indicating whether the current stream supports seeking.
/// </summary>
/// <value></value>
/// <returns>true if the stream supports seeking; otherwise, false.</returns>
- public override bool CanSeek
- {
- get
- {
- return _baseStream.CanSeek;
- }
- }
+ public override bool CanSeek => _baseStream.CanSeek;
/// <summary>
/// Gets a value indicating whether the current stream supports writing.
/// </summary>
/// <value></value>
/// <returns>true if the stream supports writing; otherwise, false.</returns>
- public override bool CanWrite
- {
- get
- {
- return _baseStream.CanWrite;
- }
- }
+ public override bool CanWrite => _baseStream.CanWrite;
/// <summary>
/// Gets the length in bytes of the stream.
@@ -115,13 +88,7 @@ namespace Emby.Server.Implementations.IO
/// <returns>A long value representing the length of the stream in bytes.</returns>
/// <exception cref="T:System.NotSupportedException">The base stream does not support seeking. </exception>
/// <exception cref="T:System.ObjectDisposedException">Methods were called after the stream was closed. </exception>
- public override long Length
- {
- get
- {
- return _baseStream.Length;
- }
- }
+ public override long Length => _baseStream.Length;
/// <summary>
/// Gets or sets the position within the current stream.
@@ -133,14 +100,8 @@ namespace Emby.Server.Implementations.IO
/// <exception cref="T:System.ObjectDisposedException">Methods were called after the stream was closed. </exception>
public override long Position
{
- get
- {
- return _baseStream.Position;
- }
- set
- {
- _baseStream.Position = value;
- }
+ get => _baseStream.Position;
+ set => _baseStream.Position = value;
}
#endregion
@@ -158,12 +119,12 @@ namespace Emby.Server.Implementations.IO
{
if (baseStream == null)
{
- throw new ArgumentNullException("baseStream");
+ throw new ArgumentNullException(nameof(baseStream));
}
if (maximumBytesPerSecond < 0)
{
- throw new ArgumentOutOfRangeException("maximumBytesPerSecond",
+ throw new ArgumentOutOfRangeException(nameof(maximumBytesPerSecond),
maximumBytesPerSecond, "The maximum number of bytes per second can't be negative.");
}
diff --git a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs
index be17893d8..964e38962 100644
--- a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs
+++ b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs
@@ -193,10 +193,7 @@ namespace Emby.Server.Implementations.Images
return outputPath;
}
- public string Name
- {
- get { return "Dynamic Image Provider"; }
- }
+ public string Name => "Dynamic Image Provider";
protected virtual string CreateImage(BaseItem item,
List<BaseItem> itemsWithImages,
@@ -232,10 +229,7 @@ namespace Emby.Server.Implementations.Images
throw new ArgumentException("Unexpected image type");
}
- protected virtual int MaxImageAgeDays
- {
- get { return 7; }
- }
+ protected virtual int MaxImageAgeDays => 7;
public bool HasChanged(BaseItem item, IDirectoryService directoryServicee)
{
@@ -293,14 +287,7 @@ namespace Emby.Server.Implementations.Images
return true;
}
- public int Order
- {
- get
- {
- // Run before the default image provider which will download placeholders
- return 0;
- }
- }
+ public int Order => 0;
protected string CreateSingleImage(List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType)
{
diff --git a/Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs b/Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs
index 7c79a7c69..775b5d283 100644
--- a/Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs
+++ b/Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs
@@ -67,7 +67,7 @@ namespace Emby.Server.Implementations.Library
if (string.IsNullOrWhiteSpace(newPasswordHash))
{
- throw new ArgumentNullException("newPasswordHash");
+ throw new ArgumentNullException(nameof(newPasswordHash));
}
user.Password = newPasswordHash;
diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs
index 451f16bef..464fd2863 100644
--- a/Emby.Server.Implementations/Library/LibraryManager.cs
+++ b/Emby.Server.Implementations/Library/LibraryManager.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Common.Extensions;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Progress;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
@@ -147,13 +147,7 @@ namespace Emby.Server.Implementations.Library
/// Gets the library items cache.
/// </summary>
/// <value>The library items cache.</value>
- private ConcurrentDictionary<Guid, BaseItem> LibraryItemsCache
- {
- get
- {
- return _libraryItemsCache;
- }
- }
+ private ConcurrentDictionary<Guid, BaseItem> LibraryItemsCache => _libraryItemsCache;
private readonly IFileSystem _fileSystem;
@@ -188,7 +182,6 @@ namespace Emby.Server.Implementations.Library
/// Adds the parts.
/// </summary>
/// <param name="rules">The rules.</param>
- /// <param name="pluginFolders">The plugin folders.</param>
/// <param name="resolvers">The resolvers.</param>
/// <param name="introProviders">The intro providers.</param>
/// <param name="itemComparers">The item comparers.</param>
@@ -277,7 +270,7 @@ namespace Emby.Server.Implementations.Library
{
if (item == null)
{
- throw new ArgumentNullException("item");
+ throw new ArgumentNullException(nameof(item));
}
if (item is IItemByName)
{
@@ -317,7 +310,7 @@ namespace Emby.Server.Implementations.Library
{
if (item == null)
{
- throw new ArgumentNullException("item");
+ throw new ArgumentNullException(nameof(item));
}
var parent = item.GetOwner() ?? item.GetParent();
@@ -329,7 +322,7 @@ namespace Emby.Server.Implementations.Library
{
if (item == null)
{
- throw new ArgumentNullException("item");
+ throw new ArgumentNullException(nameof(item));
}
if (item.SourceType == SourceType.Channel)
@@ -449,7 +442,7 @@ namespace Emby.Server.Implementations.Library
ReportItemRemoved(item, parent);
}
- private IEnumerable<string> GetMetadataPaths(BaseItem item, IEnumerable<BaseItem> children)
+ private static IEnumerable<string> GetMetadataPaths(BaseItem item, IEnumerable<BaseItem> children)
{
var list = new List<string>
{
@@ -502,11 +495,11 @@ namespace Emby.Server.Implementations.Library
{
if (string.IsNullOrEmpty(key))
{
- throw new ArgumentNullException("key");
+ throw new ArgumentNullException(nameof(key));
}
if (type == null)
{
- throw new ArgumentNullException("type");
+ throw new ArgumentNullException(nameof(type));
}
if (key.StartsWith(ConfigurationManager.ApplicationPaths.ProgramDataPath))
@@ -542,7 +535,7 @@ namespace Emby.Server.Implementations.Library
{
if (fileInfo == null)
{
- throw new ArgumentNullException("fileInfo");
+ throw new ArgumentNullException(nameof(fileInfo));
}
var fullPath = fileInfo.FullName;
@@ -823,7 +816,7 @@ namespace Emby.Server.Implementations.Library
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
//_logger.LogInformation("FindByPath {0}", path);
@@ -921,7 +914,7 @@ namespace Emby.Server.Implementations.Library
{
if (value <= 0)
{
- throw new ArgumentOutOfRangeException("Years less than or equal to 0 are invalid.");
+ throw new ArgumentOutOfRangeException(nameof(value),"Years less than or equal to 0 are invalid.");
}
var name = value.ToString(CultureInfo.InvariantCulture);
@@ -1249,7 +1242,7 @@ namespace Emby.Server.Implementations.Library
{
if (id.Equals(Guid.Empty))
{
- throw new ArgumentNullException("id");
+ throw new ArgumentNullException(nameof(id));
}
BaseItem item;
@@ -1828,7 +1821,7 @@ namespace Emby.Server.Implementations.Library
/// Creates the item.
/// </summary>
/// <param name="item">The item.</param>
- /// <param name="cancellationToken">The cancellation token.</param>
+ /// <param name="parent">The parent item.</param>
/// <returns>Task.</returns>
public void CreateItem(BaseItem item, BaseItem parent)
{
@@ -2023,7 +2016,7 @@ namespace Emby.Server.Implementations.Library
return GetCollectionFoldersInternal(item, allUserRootChildren);
}
- private List<Folder> GetCollectionFoldersInternal(BaseItem item, List<Folder> allUserRootChildren)
+ private static List<Folder> GetCollectionFoldersInternal(BaseItem item, List<Folder> allUserRootChildren)
{
return allUserRootChildren
.Where(i => string.Equals(i.Path, item.Path, StringComparison.OrdinalIgnoreCase) || i.PhysicalLocations.Contains(item.Path, StringComparer.OrdinalIgnoreCase))
@@ -2247,7 +2240,7 @@ namespace Emby.Server.Implementations.Library
{
if (parent == null)
{
- throw new ArgumentNullException("parent");
+ throw new ArgumentNullException(nameof(parent));
}
var name = parent.Name;
@@ -2313,7 +2306,7 @@ namespace Emby.Server.Implementations.Library
{
if (string.IsNullOrEmpty(name))
{
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
}
var parentIdString = parentId.Equals(Guid.Empty) ? null : parentId.ToString("N");
@@ -2708,15 +2701,15 @@ namespace Emby.Server.Implementations.Library
{
if (string.IsNullOrWhiteSpace(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
if (string.IsNullOrWhiteSpace(from))
{
- throw new ArgumentNullException("from");
+ throw new ArgumentNullException(nameof(from));
}
if (string.IsNullOrWhiteSpace(to))
{
- throw new ArgumentNullException("to");
+ throw new ArgumentNullException(nameof(to));
}
from = from.Trim();
@@ -2864,7 +2857,7 @@ namespace Emby.Server.Implementations.Library
{
if (string.IsNullOrWhiteSpace(name))
{
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
}
name = _fileSystem.GetValidFilename(name);
@@ -2937,7 +2930,7 @@ namespace Emby.Server.Implementations.Library
});
}
- private bool ValidateNetworkPath(string path)
+ private static bool ValidateNetworkPath(string path)
{
//if (Environment.OSVersion.Platform == PlatformID.Win32NT)
//{
@@ -2962,14 +2955,14 @@ namespace Emby.Server.Implementations.Library
{
if (pathInfo == null)
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(pathInfo));
}
var path = pathInfo.Path;
if (string.IsNullOrWhiteSpace(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
if (!_fileSystem.DirectoryExists(path))
@@ -3017,7 +3010,7 @@ namespace Emby.Server.Implementations.Library
{
if (pathInfo == null)
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(pathInfo));
}
if (!string.IsNullOrWhiteSpace(pathInfo.NetworkPath) && !ValidateNetworkPath(pathInfo.NetworkPath))
@@ -3075,7 +3068,7 @@ namespace Emby.Server.Implementations.Library
{
if (string.IsNullOrWhiteSpace(name))
{
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
}
var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
@@ -3116,7 +3109,7 @@ namespace Emby.Server.Implementations.Library
{
if (string.IsNullOrWhiteSpace(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
var removeList = new List<NameValuePair>();
@@ -3148,7 +3141,7 @@ namespace Emby.Server.Implementations.Library
{
if (string.IsNullOrEmpty(mediaPath))
{
- throw new ArgumentNullException("mediaPath");
+ throw new ArgumentNullException(nameof(mediaPath));
}
var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs
index ddda4b2c3..3578d8763 100644
--- a/Emby.Server.Implementations/Library/MediaSourceManager.cs
+++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Common.Extensions;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
@@ -74,7 +74,7 @@ namespace Emby.Server.Implementations.Library
return list;
}
- private bool StreamSupportsExternalStream(MediaStream stream)
+ private static bool StreamSupportsExternalStream(MediaStream stream)
{
if (stream.IsExternal)
{
@@ -261,7 +261,7 @@ namespace Emby.Server.Implementations.Library
}
}
- private void SetKeyProperties(IMediaSourceProvider provider, MediaSourceInfo mediaSource)
+ private static void SetKeyProperties(IMediaSourceProvider provider, MediaSourceInfo mediaSource)
{
var prefix = provider.GetType().FullName.GetMD5().ToString("N") + LiveStreamIdDelimeter;
@@ -292,7 +292,7 @@ namespace Emby.Server.Implementations.Library
{
if (item == null)
{
- throw new ArgumentNullException("item");
+ throw new ArgumentNullException(nameof(item));
}
var hasMediaSources = (IHasMediaSources)item;
@@ -401,7 +401,7 @@ namespace Emby.Server.Implementations.Library
}
}
- private IEnumerable<MediaSourceInfo> SortMediaSources(IEnumerable<MediaSourceInfo> sources)
+ private static IEnumerable<MediaSourceInfo> SortMediaSources(IEnumerable<MediaSourceInfo> sources)
{
return sources.OrderBy(i =>
{
@@ -501,7 +501,7 @@ namespace Emby.Server.Implementations.Library
}, liveStream as IDirectStreamProvider);
}
- private void AddMediaInfo(MediaSourceInfo mediaSource, bool isAudio)
+ private static void AddMediaInfo(MediaSourceInfo mediaSource, bool isAudio)
{
mediaSource.DefaultSubtitleStreamIndex = null;
@@ -629,6 +629,7 @@ namespace Emby.Server.Implementations.Library
}
catch (Exception ex)
{
+ _logger.LogDebug(ex, "_jsonSerializer.DeserializeFromFile threw an exception.");
}
}
@@ -759,7 +760,7 @@ namespace Emby.Server.Implementations.Library
{
if (string.IsNullOrEmpty(id))
{
- throw new ArgumentNullException("id");
+ throw new ArgumentNullException(nameof(id));
}
var info = await GetLiveStreamInfo(id, cancellationToken).ConfigureAwait(false);
@@ -770,7 +771,7 @@ namespace Emby.Server.Implementations.Library
{
if (string.IsNullOrEmpty(id))
{
- throw new ArgumentNullException("id");
+ throw new ArgumentNullException(nameof(id));
}
await _liveStreamSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
@@ -803,7 +804,7 @@ namespace Emby.Server.Implementations.Library
{
if (string.IsNullOrEmpty(id))
{
- throw new ArgumentNullException("id");
+ throw new ArgumentNullException(nameof(id));
}
await _liveStreamSemaphore.WaitAsync().ConfigureAwait(false);
diff --git a/Emby.Server.Implementations/Library/PathExtensions.cs b/Emby.Server.Implementations/Library/PathExtensions.cs
index 28ed2f53c..2d3019d17 100644
--- a/Emby.Server.Implementations/Library/PathExtensions.cs
+++ b/Emby.Server.Implementations/Library/PathExtensions.cs
@@ -16,12 +16,12 @@ namespace Emby.Server.Implementations.Library
{
if (string.IsNullOrEmpty(str))
{
- throw new ArgumentNullException("str");
+ throw new ArgumentNullException(nameof(str));
}
if (string.IsNullOrEmpty(attrib))
{
- throw new ArgumentNullException("attrib");
+ throw new ArgumentNullException(nameof(attrib));
}
string srch = "[" + attrib + "=";
diff --git a/Emby.Server.Implementations/Library/ResolverHelper.cs b/Emby.Server.Implementations/Library/ResolverHelper.cs
index 14b28966a..027d82c58 100644
--- a/Emby.Server.Implementations/Library/ResolverHelper.cs
+++ b/Emby.Server.Implementations/Library/ResolverHelper.cs
@@ -117,15 +117,15 @@ namespace Emby.Server.Implementations.Library
{
if (fileSystem == null)
{
- throw new ArgumentNullException("fileSystem");
+ throw new ArgumentNullException(nameof(fileSystem));
}
if (item == null)
{
- throw new ArgumentNullException("item");
+ throw new ArgumentNullException(nameof(item));
}
if (args == null)
{
- throw new ArgumentNullException("args");
+ throw new ArgumentNullException(nameof(args));
}
// See if a different path came out of the resolver than what went in
diff --git a/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs
index 8872bd641..c7bd1a602 100644
--- a/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Resolvers;
using MediaBrowser.Model.Entities;
using System;
@@ -30,10 +30,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
/// Gets the priority.
/// </summary>
/// <value>The priority.</value>
- public override ResolverPriority Priority
- {
- get { return ResolverPriority.Fourth; }
- }
+ public override ResolverPriority Priority => ResolverPriority.Fourth;
public MultiItemResolverResult ResolveMultiple(Folder parent,
List<FileSystemMetadata> files,
@@ -264,12 +261,12 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
result.Extras.Any(i => ContainsFile(i, file));
}
- private bool ContainsFile(AudioBookFileInfo result, FileSystemMetadata file)
+ private static bool ContainsFile(AudioBookFileInfo result, FileSystemMetadata file)
{
return string.Equals(result.Path, file.FullName, StringComparison.OrdinalIgnoreCase);
}
- private bool IsIgnored(string filename)
+ private static bool IsIgnored(string filename)
{
return false;
}
diff --git a/Emby.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs
index dbfcf41e8..da5fe48cd 100644
--- a/Emby.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs
@@ -36,14 +36,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
/// Gets the priority.
/// </summary>
/// <value>The priority.</value>
- public override ResolverPriority Priority
- {
- get
- {
- // Behind special folder resolver
- return ResolverPriority.Second;
- }
- }
+ public override ResolverPriority Priority => ResolverPriority.Second;
/// <summary>
/// Resolves the specified args.
diff --git a/Emby.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs
index 71ccd7da8..b3a5c27c8 100644
--- a/Emby.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs
@@ -35,14 +35,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
/// Gets the priority.
/// </summary>
/// <value>The priority.</value>
- public override ResolverPriority Priority
- {
- get
- {
- // Behind special folder resolver
- return ResolverPriority.Second;
- }
- }
+ public override ResolverPriority Priority => ResolverPriority.Second;
/// <summary>
/// Resolves the specified args.
diff --git a/Emby.Server.Implementations/Library/Resolvers/FolderResolver.cs b/Emby.Server.Implementations/Library/Resolvers/FolderResolver.cs
index 5e73baa5c..47e7f7344 100644
--- a/Emby.Server.Implementations/Library/Resolvers/FolderResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/FolderResolver.cs
@@ -13,10 +13,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
/// Gets the priority.
/// </summary>
/// <value>The priority.</value>
- public override ResolverPriority Priority
- {
- get { return ResolverPriority.Last; }
- }
+ public override ResolverPriority Priority => ResolverPriority.Last;
/// <summary>
/// Resolves the specified args.
diff --git a/Emby.Server.Implementations/Library/Resolvers/ItemResolver.cs b/Emby.Server.Implementations/Library/Resolvers/ItemResolver.cs
index b4a37be5f..529916619 100644
--- a/Emby.Server.Implementations/Library/Resolvers/ItemResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/ItemResolver.cs
@@ -25,13 +25,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
/// Gets the priority.
/// </summary>
/// <value>The priority.</value>
- public virtual ResolverPriority Priority
- {
- get
- {
- return ResolverPriority.First;
- }
- }
+ public virtual ResolverPriority Priority => ResolverPriority.First;
/// <summary>
/// Sets initial values on the newly resolved item
diff --git a/Emby.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs
index b9aca1417..d3ab4dd37 100644
--- a/Emby.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Entities;
@@ -61,7 +61,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
/// Sets the provider id from path.
/// </summary>
/// <param name="item">The item.</param>
- private void SetProviderIdFromPath(BaseItem item)
+ private static void SetProviderIdFromPath(BaseItem item)
{
//we need to only look at the name of this actual item (not parents)
var justName = Path.GetFileName(item.Path);
diff --git a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
index 68b6c57ae..0a45317a4 100644
--- a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
@@ -27,17 +27,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
/// Gets the priority.
/// </summary>
/// <value>The priority.</value>
- public override ResolverPriority Priority
- {
- get
- {
- // Give plugins a chance to catch iso's first
- // Also since we have to loop through child files looking for videos,
- // see if we can avoid some of that by letting other resolvers claim folders first
- // Also run after series resolver
- return ResolverPriority.Third;
- }
- }
+ public override ResolverPriority Priority => ResolverPriority.Third;
public MultiItemResolverResult ResolveMultiple(Folder parent,
List<FileSystemMetadata> files,
@@ -176,7 +166,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
return result;
}
- private bool IsIgnored(string filename)
+ private static bool IsIgnored(string filename)
{
// Ignore samples
var sampleFilename = " " + filename.Replace(".", " ", StringComparison.OrdinalIgnoreCase)
@@ -204,7 +194,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
result.Extras.Any(i => ContainsFile(i, file));
}
- private bool ContainsFile(VideoFileInfo result, FileSystemMetadata file)
+ private static bool ContainsFile(VideoFileInfo result, FileSystemMetadata file)
{
return string.Equals(result.Path, file.FullName, StringComparison.OrdinalIgnoreCase);
}
@@ -330,7 +320,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
/// Sets the provider id from path.
/// </summary>
/// <param name="item">The item.</param>
- private void SetProviderIdsFromPath(Video item)
+ private static void SetProviderIdsFromPath(Video item)
{
if (item is Movie || item is MusicVideo)
{
diff --git a/Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs b/Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs
index 311abf14e..a073e0bd5 100644
--- a/Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs
@@ -79,13 +79,6 @@ namespace Emby.Server.Implementations.Library.Resolvers
return false;
}
- public override ResolverPriority Priority
- {
- get
- {
- // Behind special folder resolver
- return ResolverPriority.Second;
- }
- }
+ public override ResolverPriority Priority => ResolverPriority.Second;
}
}
diff --git a/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs b/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs
index 6a1f8ec6f..5cf5cd3ad 100644
--- a/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs
@@ -26,10 +26,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
/// Gets the priority.
/// </summary>
/// <value>The priority.</value>
- public override ResolverPriority Priority
- {
- get { return ResolverPriority.First; }
- }
+ public override ResolverPriority Priority => ResolverPriority.First;
/// <summary>
/// Resolves the specified args.
diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
index 0fe42fa73..4bfedf3c6 100644
--- a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
@@ -1,4 +1,4 @@
-using System.Globalization;
+using System.Globalization;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
@@ -28,6 +28,9 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
/// Initializes a new instance of the <see cref="SeasonResolver"/> class.
/// </summary>
/// <param name="config">The config.</param>
+ /// <param name="libraryManager">The library manager.</param>
+ /// <param name="localization">The localization</param>
+ /// <param name="logger">The logger</param>
public SeasonResolver(IServerConfigurationManager config, ILibraryManager libraryManager, ILocalizationManager localization, ILogger logger)
{
_config = config;
diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs
index 32e8b6120..7d2865f0d 100644
--- a/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Controller.Entities.TV;
+using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Resolvers;
@@ -38,13 +38,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
/// Gets the priority.
/// </summary>
/// <value>The priority.</value>
- public override ResolverPriority Priority
- {
- get
- {
- return ResolverPriority.Second;
- }
- }
+ public override ResolverPriority Priority => ResolverPriority.Second;
/// <summary>
/// Resolves the specified args.
@@ -195,7 +189,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
{
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
var extension = Path.GetExtension(path);
@@ -236,7 +230,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
/// </summary>
/// <param name="item">The item.</param>
/// <param name="path">The path.</param>
- private void SetProviderIdFromPath(Series item, string path)
+ private static void SetProviderIdFromPath(Series item, string path)
{
var justName = Path.GetFileName(path);
diff --git a/Emby.Server.Implementations/Library/SearchEngine.cs b/Emby.Server.Implementations/Library/SearchEngine.cs
index 1212ba549..bbb139439 100644
--- a/Emby.Server.Implementations/Library/SearchEngine.cs
+++ b/Emby.Server.Implementations/Library/SearchEngine.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using Microsoft.Extensions.Logging;
@@ -64,7 +64,7 @@ namespace Emby.Server.Implementations.Library
};
}
- private void AddIfMissing(List<string> list, string value)
+ private static void AddIfMissing(List<string> list, string value)
{
if (!list.Contains(value, StringComparer.OrdinalIgnoreCase))
{
@@ -85,7 +85,7 @@ namespace Emby.Server.Implementations.Library
if (string.IsNullOrEmpty(searchTerm))
{
- throw new ArgumentNullException("searchTerm");
+ throw new ArgumentNullException(nameof(searchTerm));
}
searchTerm = searchTerm.Trim().RemoveDiacritics();
diff --git a/Emby.Server.Implementations/Library/UserDataManager.cs b/Emby.Server.Implementations/Library/UserDataManager.cs
index 27ba32c0c..3ca4b6b10 100644
--- a/Emby.Server.Implementations/Library/UserDataManager.cs
+++ b/Emby.Server.Implementations/Library/UserDataManager.cs
@@ -53,11 +53,11 @@ namespace Emby.Server.Implementations.Library
{
if (userData == null)
{
- throw new ArgumentNullException("userData");
+ throw new ArgumentNullException(nameof(userData));
}
if (item == null)
{
- throw new ArgumentNullException("item");
+ throw new ArgumentNullException(nameof(item));
}
cancellationToken.ThrowIfCancellationRequested();
@@ -150,7 +150,7 @@ namespace Emby.Server.Implementations.Library
/// Gets the internal key.
/// </summary>
/// <returns>System.String.</returns>
- private string GetCacheKey(long internalUserId, Guid itemId)
+ private static string GetCacheKey(long internalUserId, Guid itemId)
{
return internalUserId.ToString(CultureInfo.InvariantCulture) + "-" + itemId.ToString("N");
}
@@ -198,7 +198,7 @@ namespace Emby.Server.Implementations.Library
{
if (data == null)
{
- throw new ArgumentNullException("data");
+ throw new ArgumentNullException(nameof(data));
}
return new UserItemDataDto
@@ -226,7 +226,7 @@ namespace Emby.Server.Implementations.Library
// If a position has been reported, and if we know the duration
if (positionTicks > 0 && hasRuntime)
{
- var pctIn = Decimal.Divide(positionTicks, runtimeTicks) * 100;
+ var pctIn = decimal.Divide(positionTicks, runtimeTicks) * 100;
// Don't track in very beginning
if (pctIn < _config.Configuration.MinResumePct)
diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs
index 679116fc0..8f26dfe42 100644
--- a/Emby.Server.Implementations/Library/UserManager.cs
+++ b/Emby.Server.Implementations/Library/UserManager.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Common.Events;
+using MediaBrowser.Common.Events;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
@@ -44,7 +44,7 @@ namespace Emby.Server.Implementations.Library
/// Gets the users.
/// </summary>
/// <value>The users.</value>
- public IEnumerable<User> Users { get { return _users; } }
+ public IEnumerable<User> Users => _users;
private User[] _users;
@@ -163,7 +163,7 @@ namespace Emby.Server.Implementations.Library
{
if (id.Equals(Guid.Empty))
{
- throw new ArgumentNullException("id");
+ throw new ArgumentNullException(nameof(id));
}
return Users.FirstOrDefault(u => u.Id == id);
@@ -183,7 +183,7 @@ namespace Emby.Server.Implementations.Library
{
if (string.IsNullOrWhiteSpace(name))
{
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
}
return Users.FirstOrDefault(u => string.Equals(u.Name, name, StringComparison.OrdinalIgnoreCase));
@@ -222,7 +222,7 @@ namespace Emby.Server.Implementations.Library
return true;
}
- private bool IsValidUsernameCharacter(char i)
+ private static bool IsValidUsernameCharacter(char i)
{
return !char.Equals(i, '<') && !char.Equals(i, '>');
}
@@ -251,7 +251,7 @@ namespace Emby.Server.Implementations.Library
{
if (string.IsNullOrWhiteSpace(username))
{
- throw new ArgumentNullException("username");
+ throw new ArgumentNullException(nameof(username));
}
var user = Users
@@ -344,7 +344,7 @@ namespace Emby.Server.Implementations.Library
return success ? user : null;
}
- private string GetAuthenticationProviderId(IAuthenticationProvider provider)
+ private static string GetAuthenticationProviderId(IAuthenticationProvider provider)
{
return provider.GetType().FullName;
}
@@ -526,7 +526,7 @@ namespace Emby.Server.Implementations.Library
{
if (user == null)
{
- throw new ArgumentNullException("user");
+ throw new ArgumentNullException(nameof(user));
}
var hasConfiguredPassword = GetAuthenticationProvider(user).HasPassword(user).Result;
@@ -625,12 +625,12 @@ namespace Emby.Server.Implementations.Library
{
if (user == null)
{
- throw new ArgumentNullException("user");
+ throw new ArgumentNullException(nameof(user));
}
if (string.IsNullOrEmpty(newName))
{
- throw new ArgumentNullException("newName");
+ throw new ArgumentNullException(nameof(newName));
}
if (Users.Any(u => u.Id != user.Id && u.Name.Equals(newName, StringComparison.OrdinalIgnoreCase)))
@@ -658,7 +658,7 @@ namespace Emby.Server.Implementations.Library
{
if (user == null)
{
- throw new ArgumentNullException("user");
+ throw new ArgumentNullException(nameof(user));
}
if (user.Id.Equals(Guid.Empty) || !Users.Any(u => u.Id.Equals(user.Id)))
@@ -689,7 +689,7 @@ namespace Emby.Server.Implementations.Library
{
if (string.IsNullOrWhiteSpace(name))
{
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
}
if (!IsValidUsername(name))
@@ -737,7 +737,7 @@ namespace Emby.Server.Implementations.Library
{
if (user == null)
{
- throw new ArgumentNullException("user");
+ throw new ArgumentNullException(nameof(user));
}
var allUsers = Users.ToList();
@@ -804,7 +804,7 @@ namespace Emby.Server.Implementations.Library
{
if (user == null)
{
- throw new ArgumentNullException("user");
+ throw new ArgumentNullException(nameof(user));
}
if (user.ConnectLinkType.HasValue && user.ConnectLinkType.Value == UserLinkType.Guest)
@@ -823,7 +823,7 @@ namespace Emby.Server.Implementations.Library
{
if (user == null)
{
- throw new ArgumentNullException("user");
+ throw new ArgumentNullException(nameof(user));
}
if (newPassword != null)
@@ -833,7 +833,7 @@ namespace Emby.Server.Implementations.Library
if (string.IsNullOrWhiteSpace(newPasswordHash))
{
- throw new ArgumentNullException("newPasswordHash");
+ throw new ArgumentNullException(nameof(newPasswordHash));
}
user.EasyPassword = newPasswordHash;
@@ -848,7 +848,7 @@ namespace Emby.Server.Implementations.Library
/// </summary>
/// <param name="name">The name.</param>
/// <returns>User.</returns>
- private User InstantiateNewUser(string name)
+ private static User InstantiateNewUser(string name)
{
return new User
{
@@ -861,10 +861,7 @@ namespace Emby.Server.Implementations.Library
};
}
- private string PasswordResetFile
- {
- get { return Path.Combine(ConfigurationManager.ApplicationPaths.ProgramDataPath, "passwordreset.txt"); }
- }
+ private string PasswordResetFile => Path.Combine(ConfigurationManager.ApplicationPaths.ProgramDataPath, "passwordreset.txt");
private string _lastPin;
private PasswordPinCreationResult _lastPasswordPinCreationResult;
@@ -1047,7 +1044,7 @@ namespace Emby.Server.Implementations.Library
}
}
- private UserPolicy GetDefaultPolicy(User user)
+ private static UserPolicy GetDefaultPolicy(User user)
{
return new UserPolicy
{
@@ -1109,12 +1106,12 @@ namespace Emby.Server.Implementations.Library
}
}
- private string GetPolicyFilePath(User user)
+ private static string GetPolicyFilePath(User user)
{
return Path.Combine(user.ConfigurationDirectoryPath, "policy.xml");
}
- private string GetConfigurationFilePath(User user)
+ private static string GetConfigurationFilePath(User user)
{
return Path.Combine(user.ConfigurationDirectoryPath, "config.xml");
}
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
index 81a47bfea..ba2aee08d 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
@@ -254,27 +254,15 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
if (requiresRefresh)
{
- await _libraryManager.ValidateMediaLibrary(new SimpleProgress<Double>(), CancellationToken.None);
+ await _libraryManager.ValidateMediaLibrary(new SimpleProgress<double>(), CancellationToken.None);
}
}
- public string Name
- {
- get { return "Emby"; }
- }
+ public string Name => "Emby";
- public string DataPath
- {
- get { return Path.Combine(_config.CommonApplicationPaths.DataPath, "livetv"); }
- }
+ public string DataPath => Path.Combine(_config.CommonApplicationPaths.DataPath, "livetv");
- private string DefaultRecordingPath
- {
- get
- {
- return Path.Combine(DataPath, "recordings");
- }
- }
+ private string DefaultRecordingPath => Path.Combine(DataPath, "recordings");
private string RecordingPath
{
@@ -288,10 +276,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
}
- public string HomePageUrl
- {
- get { return "https://github.com/jellyfin/jellyfin"; }
- }
+ public string HomePageUrl => "https://github.com/jellyfin/jellyfin";
public async Task RefreshSeriesTimers(CancellationToken cancellationToken, IProgress<double> progress)
{
@@ -491,7 +476,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
return GetEpgChannelFromTunerChannel(info, tunerChannel, epgChannels);
}
- private string GetMappedChannel(string channelId, NameValuePair[] mappings)
+ private static string GetMappedChannel(string channelId, NameValuePair[] mappings)
{
foreach (NameValuePair mapping in mappings)
{
@@ -850,7 +835,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
return Task.CompletedTask;
}
- private void UpdateExistingTimerWithNewMetadata(TimerInfo existingTimer, TimerInfo updatedTimer)
+ private static void UpdateExistingTimerWithNewMetadata(TimerInfo existingTimer, TimerInfo updatedTimer)
{
// Update the program info but retain the status
existingTimer.ChannelId = updatedTimer.ChannelId;
@@ -980,7 +965,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
if (string.IsNullOrWhiteSpace(tunerHostId))
{
- throw new ArgumentNullException("tunerHostId");
+ throw new ArgumentNullException(nameof(tunerHostId));
}
return info.EnabledTuners.Contains(tunerHostId, StringComparer.OrdinalIgnoreCase);
@@ -1114,7 +1099,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
if (string.IsNullOrWhiteSpace(channelId))
{
- throw new ArgumentNullException("channelId");
+ throw new ArgumentNullException(nameof(channelId));
}
foreach (var hostInstance in _liveTvManager.TunerHosts)
@@ -1342,7 +1327,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
if (timer == null)
{
- throw new ArgumentNullException("timer");
+ throw new ArgumentNullException(nameof(timer));
}
LiveTvProgram programInfo = null;
@@ -1795,7 +1780,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
}
- private string GetPostProcessArguments(string path, string arguments)
+ private static string GetPostProcessArguments(string path, string arguments)
{
return arguments.Replace("{path}", path, StringComparison.OrdinalIgnoreCase);
}
@@ -2501,7 +2486,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
if (seriesTimer == null)
{
- throw new ArgumentNullException("seriesTimer");
+ throw new ArgumentNullException(nameof(seriesTimer));
}
var query = new InternalItemsQuery
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
index 4ea83b7ac..5463f78c2 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
@@ -55,14 +55,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
_assemblyInfo = assemblyInfo;
}
- private bool CopySubtitles
- {
- get
- {
- return false;
- //return string.Equals(OutputFormat, "mkv", StringComparison.OrdinalIgnoreCase);
- }
- }
+ private static bool CopySubtitles => false;
public string GetOutputPath(MediaSourceInfo mediaSource, string targetFile)
{
@@ -226,7 +219,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
return inputModifier + " " + commandLineArgs;
}
- private string GetAudioArgs(MediaSourceInfo mediaSource)
+ private static string GetAudioArgs(MediaSourceInfo mediaSource)
{
var mediaStreams = mediaSource.MediaStreams ?? new List<MediaStream>();
var inputAudioCodec = mediaStreams.Where(i => i.Type == MediaStreamType.Audio).Select(i => i.Codec).FirstOrDefault() ?? string.Empty;
@@ -242,7 +235,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
//return "-codec:a:0 aac -strict experimental -ab 320000";
}
- private bool EncodeVideo(MediaSourceInfo mediaSource)
+ private static bool EncodeVideo(MediaSourceInfo mediaSource)
{
return false;
}
@@ -383,6 +376,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
catch (ObjectDisposedException)
{
+ // TODO Investigate and properly fix.
// Don't spam the log. This doesn't seem to throw in windows, but sometimes under linux
}
catch (Exception ex)
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs
index 9f179dc2c..593f98881 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs
@@ -68,7 +68,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
if (newList == null)
{
- throw new ArgumentNullException("newList");
+ throw new ArgumentNullException(nameof(newList));
}
var file = _dataPath + ".json";
@@ -85,7 +85,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
if (item == null)
{
- throw new ArgumentNullException("item");
+ throw new ArgumentNullException(nameof(item));
}
var list = GetAll().ToList();
@@ -106,7 +106,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
if (item == null)
{
- throw new ArgumentNullException("item");
+ throw new ArgumentNullException(nameof(item));
}
var list = GetAll().ToList();
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs
index e4ab34770..bdc6ae009 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Concurrent;
using System.Globalization;
using System.Linq;
@@ -90,7 +90,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
AddOrUpdateSystemTimer(item);
}
- private bool ShouldStartTimer(TimerInfo item)
+ private static bool ShouldStartTimer(TimerInfo item)
{
if (item.Status == RecordingStatus.Completed ||
item.Status == RecordingStatus.Cancelled)
diff --git a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
index e8ffd0caa..0ba8c8b42 100644
--- a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
+++ b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
@@ -1,4 +1,4 @@
-using System.Net;
+using System.Net;
using MediaBrowser.Common;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.LiveTv;
@@ -38,12 +38,9 @@ namespace Emby.Server.Implementations.LiveTv.Listings
_appHost = appHost;
}
- private string UserAgent
- {
- get { return "Emby/" + _appHost.ApplicationVersion; }
- }
+ private string UserAgent => "Emby/" + _appHost.ApplicationVersion;
- private List<string> GetScheduleRequestDates(DateTime startDateUtc, DateTime endDateUtc)
+ private static List<string> GetScheduleRequestDates(DateTime startDateUtc, DateTime endDateUtc)
{
List<string> dates = new List<string>();
@@ -63,7 +60,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
{
if (string.IsNullOrEmpty(channelId))
{
- throw new ArgumentNullException("channelId");
+ throw new ArgumentNullException(nameof(channelId));
}
// Normalize incoming input
@@ -189,7 +186,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
}
- private int GetSizeOrder(ScheduleDirect.ImageData image)
+ private static int GetSizeOrder(ScheduleDirect.ImageData image)
{
if (!string.IsNullOrWhiteSpace(image.height))
{
@@ -202,7 +199,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
return 0;
}
- private string GetChannelNumber(ScheduleDirect.Map map)
+ private static string GetChannelNumber(ScheduleDirect.Map map)
{
var channelNumber = map.logicalChannelNumber;
@@ -218,7 +215,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
return channelNumber.TrimStart('0');
}
- private bool IsMovie(ScheduleDirect.ProgramDetails programInfo)
+ private static bool IsMovie(ScheduleDirect.ProgramDetails programInfo)
{
return string.Equals(programInfo.entityType, "movie", StringComparison.OrdinalIgnoreCase);
}
@@ -390,7 +387,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
return info;
}
- private DateTime GetDate(string value)
+ private static DateTime GetDate(string value)
{
var date = DateTime.ParseExact(value, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", CultureInfo.InvariantCulture);
@@ -429,7 +426,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
}
- private double GetAspectRatio(ScheduleDirect.ImageData i)
+ private static double GetAspectRatio(ScheduleDirect.ImageData i)
{
int width = 0;
int height = 0;
@@ -664,7 +661,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
}
- options.RequestHeaders["token"] = await GetToken(providerInfo, options.CancellationToken).ConfigureAwait(false);;
+ options.RequestHeaders["token"] = await GetToken(providerInfo, options.CancellationToken).ConfigureAwait(false);
return await Post(options, false, providerInfo).ConfigureAwait(false);
}
@@ -765,16 +762,10 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
}
- public string Name
- {
- get { return "Schedules Direct"; }
- }
+ public string Name => "Schedules Direct";
public static string TypeName = "SchedulesDirect";
- public string Type
- {
- get { return TypeName; }
- }
+ public string Type => TypeName;
private async Task<bool> HasLineup(ListingsProviderInfo info, CancellationToken cancellationToken)
{
@@ -951,7 +942,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
return null;
}
- private string NormalizeName(string value)
+ private static string NormalizeName(string value)
{
return value.Replace(" ", string.Empty).Replace("-", string.Empty);
}
diff --git a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
index 4d7c7fef4..2b1ee84a8 100644
--- a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
+++ b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
@@ -36,15 +36,9 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
_zipClient = zipClient;
}
- public string Name
- {
- get { return "XmlTV"; }
- }
+ public string Name => "XmlTV";
- public string Type
- {
- get { return "xmltv"; }
- }
+ public string Type => "xmltv";
private string GetLanguage(ListingsProviderInfo info)
{
@@ -78,7 +72,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
{
CancellationToken = cancellationToken,
Url = path,
- Progress = new SimpleProgress<Double>(),
+ Progress = new SimpleProgress<double>(),
DecompressionMethod = CompressionMethod.Gzip,
// It's going to come back gzipped regardless of this value
@@ -164,7 +158,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
{
if (string.IsNullOrWhiteSpace(channelId))
{
- throw new ArgumentNullException("channelId");
+ throw new ArgumentNullException(nameof(channelId));
}
/*
@@ -187,7 +181,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
.Select(p => GetProgramInfo(p, info));
}
- private ProgramInfo GetProgramInfo(XmlTvProgram program, ListingsProviderInfo info)
+ private static ProgramInfo GetProgramInfo(XmlTvProgram program, ListingsProviderInfo info)
{
string episodeTitle = program.Episode?.Title;
@@ -210,9 +204,9 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
IsMovie = program.Categories.Any(c => info.MovieCategories.Contains(c, StringComparer.OrdinalIgnoreCase)),
IsNews = program.Categories.Any(c => info.NewsCategories.Contains(c, StringComparer.OrdinalIgnoreCase)),
IsSports = program.Categories.Any(c => info.SportsCategories.Contains(c, StringComparer.OrdinalIgnoreCase)),
- ImageUrl = program.Icon != null && !String.IsNullOrEmpty(program.Icon.Source) ? program.Icon.Source : null,
- HasImage = program.Icon != null && !String.IsNullOrEmpty(program.Icon.Source),
- OfficialRating = program.Rating != null && !String.IsNullOrEmpty(program.Rating.Value) ? program.Rating.Value : null,
+ ImageUrl = program.Icon != null && !string.IsNullOrEmpty(program.Icon.Source) ? program.Icon.Source : null,
+ HasImage = program.Icon != null && !string.IsNullOrEmpty(program.Icon.Source),
+ OfficialRating = program.Rating != null && !string.IsNullOrEmpty(program.Rating.Value) ? program.Rating.Value : null,
CommunityRating = program.StarRating,
SeriesId = program.Episode == null ? null : program.Title.GetMD5().ToString("N")
};
@@ -246,7 +240,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
}
// Construct an id from the channel and start date
- programInfo.Id = String.Format("{0}_{1:O}", program.ChannelId, program.StartDate);
+ programInfo.Id = string.Format("{0}_{1:O}", program.ChannelId, program.StartDate);
if (programInfo.IsMovie)
{
@@ -294,7 +288,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
{
Id = c.Id,
Name = c.DisplayName,
- ImageUrl = c.Icon != null && !String.IsNullOrEmpty(c.Icon.Source) ? c.Icon.Source : null,
+ ImageUrl = c.Icon != null && !string.IsNullOrEmpty(c.Icon.Source) ? c.Icon.Source : null,
Number = string.IsNullOrWhiteSpace(c.Number) ? c.Id : c.Number
}).ToList();
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs
index 6fe578715..dbc7b16a2 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Common;
+using MediaBrowser.Common;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
@@ -321,6 +321,7 @@ namespace Emby.Server.Implementations.LiveTv
}
catch (Exception ex)
{
+ _logger.LogDebug(ex, "GetImageCacheTag raised an exception in LiveTvDtoService.FillImages.");
}
}
@@ -331,10 +332,10 @@ namespace Emby.Server.Implementations.LiveTv
{
try
{
- dto.ParentBackdropImageTags = new string[]
- {
- _imageProcessor.GetImageCacheTag(program, image)
- };
+ dto.ParentBackdropImageTags = new []
+ {
+ _imageProcessor.GetImageCacheTag(program, image)
+ };
dto.ParentBackdropItemId = program.Id.ToString("N");
}
catch (Exception ex)
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
index a81a0bcbb..d39c13bd0 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Progress;
using MediaBrowser.Controller.Configuration;
@@ -104,10 +104,7 @@ namespace Emby.Server.Implementations.LiveTv
/// Gets the services.
/// </summary>
/// <value>The services.</value>
- public IReadOnlyList<ILiveTvService> Services
- {
- get { return _services; }
- }
+ public IReadOnlyList<ILiveTvService> Services => _services;
private LiveTvOptions GetConfiguration()
{
@@ -167,15 +164,9 @@ namespace Emby.Server.Implementations.LiveTv
});
}
- public ITunerHost[] TunerHosts
- {
- get { return _tunerHosts; }
- }
+ public ITunerHost[] TunerHosts => _tunerHosts;
- public IListingsProvider[] ListingProviders
- {
- get { return _listingProviders; }
- }
+ public IListingsProvider[] ListingProviders => _listingProviders;
public List<NameIdPair> GetTunerHostTypes()
{
@@ -323,7 +314,7 @@ namespace Emby.Server.Implementations.LiveTv
return _services.FirstOrDefault(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase));
}
- private void Normalize(MediaSourceInfo mediaSource, ILiveTvService service, bool isVideo)
+ private static void Normalize(MediaSourceInfo mediaSource, ILiveTvService service, bool isVideo)
{
// Not all of the plugins are setting this
mediaSource.IsInfiniteStream = true;
@@ -1418,6 +1409,7 @@ namespace Emby.Server.Implementations.LiveTv
if (query.IsInProgress ?? false)
{
+ //TODO Fix The co-variant conversion between Video[] and BaseItem[], this can generate runtime issues.
result.Items = result
.Items
.OfType<Video>()
@@ -2188,7 +2180,7 @@ namespace Emby.Server.Implementations.LiveTv
return Services.Select(GetServiceInfo).ToArray();
}
- private LiveTvServiceInfo GetServiceInfo(ILiveTvService service)
+ private static LiveTvServiceInfo GetServiceInfo(ILiveTvService service)
{
return new LiveTvServiceInfo
{
@@ -2245,7 +2237,7 @@ namespace Emby.Server.Implementations.LiveTv
return service.ResetTuner(parts[1], cancellationToken);
}
- private void RemoveFields(DtoOptions options)
+ private static void RemoveFields(DtoOptions options)
{
var fields = options.Fields.ToList();
diff --git a/Emby.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs b/Emby.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs
index 225360159..3f113e370 100644
--- a/Emby.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs
+++ b/Emby.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs
@@ -20,20 +20,11 @@ namespace Emby.Server.Implementations.LiveTv
_config = config;
}
- public string Name
- {
- get { return "Refresh Guide"; }
- }
+ public string Name => "Refresh Guide";
- public string Description
- {
- get { return "Downloads channel information from live tv services."; }
- }
+ public string Description => "Downloads channel information from live tv services.";
- public string Category
- {
- get { return "Live TV"; }
- }
+ public string Category => "Live TV";
public Task Execute(System.Threading.CancellationToken cancellationToken, IProgress<double> progress)
{
@@ -60,24 +51,12 @@ namespace Emby.Server.Implementations.LiveTv
return _config.GetConfiguration<LiveTvOptions>("livetv");
}
- public bool IsHidden
- {
- get { return _liveTvManager.Services.Count == 1 && GetConfiguration().TunerHosts.Length == 0; }
- }
+ public bool IsHidden => _liveTvManager.Services.Count == 1 && GetConfiguration().TunerHosts.Length == 0;
- public bool IsEnabled
- {
- get { return true; }
- }
+ public bool IsEnabled => true;
- public bool IsLogged
- {
- get { return true; }
- }
+ public bool IsLogged => true;
- public string Key
- {
- get { return "RefreshGuide"; }
- }
+ public string Key => "RefreshGuide";
}
}
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs
index ef2010ba6..78514c1d9 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs
@@ -40,13 +40,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
FileSystem = fileSystem;
}
- public virtual bool IsSupported
- {
- get
- {
- return true;
- }
- }
+ public virtual bool IsSupported => true;
protected abstract Task<List<ChannelInfo>> GetChannelsInternal(TunerHostInfo tuner, CancellationToken cancellationToken);
public abstract string Type { get; }
@@ -140,7 +134,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
{
if (string.IsNullOrEmpty(channelId))
{
- throw new ArgumentNullException("channelId");
+ throw new ArgumentNullException(nameof(channelId));
}
if (IsValidChannelId(channelId))
@@ -175,7 +169,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
{
if (string.IsNullOrEmpty(channelId))
{
- throw new ArgumentNullException("channelId");
+ throw new ArgumentNullException(nameof(channelId));
}
if (!IsValidChannelId(channelId))
@@ -228,18 +222,13 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
throw new LiveTvConflictException();
}
- protected virtual string ChannelIdPrefix
- {
- get
- {
- return Type + "_";
- }
- }
+ protected virtual string ChannelIdPrefix => Type + "_";
+
protected virtual bool IsValidChannelId(string channelId)
{
if (string.IsNullOrEmpty(channelId))
{
- throw new ArgumentNullException("channelId");
+ throw new ArgumentNullException(nameof(channelId));
}
return channelId.StartsWith(ChannelIdPrefix, StringComparison.OrdinalIgnoreCase);
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs
index be090df0c..3ae47f3ab 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Model.Dto;
@@ -42,28 +42,13 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
_environment = environment;
}
- public string Name
- {
- get { return "HD Homerun"; }
- }
+ public string Name => "HD Homerun";
- public override string Type
- {
- get { return DeviceType; }
- }
+ public override string Type => DeviceType;
- public static string DeviceType
- {
- get { return "hdhomerun"; }
- }
+ public static string DeviceType => "hdhomerun";
- protected override string ChannelIdPrefix
- {
- get
- {
- return "hdhr_";
- }
- }
+ protected override string ChannelIdPrefix => "hdhr_";
private string GetChannelId(TunerHostInfo info, Channels i)
{
@@ -274,7 +259,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
for (int i = 0; i < model.TunerCount; ++i)
{
- var name = String.Format("Tuner {0}", i + 1);
+ var name = string.Format("Tuner {0}", i + 1);
var currentChannel = "none"; /// @todo Get current channel and map back to Station Id
var isAvailable = await manager.CheckTunerAvailability(ipInfo, i, cancellationToken).ConfigureAwait(false);
LiveTvTunerStatus status = isAvailable ? LiveTvTunerStatus.Available : LiveTvTunerStatus.LiveTv;
@@ -325,7 +310,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
return await GetTunerInfosHttp(info, cancellationToken).ConfigureAwait(false);
}
- private string GetApiUrl(TunerHostInfo info)
+ private static string GetApiUrl(TunerHostInfo info)
{
var url = info.Url;
@@ -359,7 +344,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
return Config.GetConfiguration<EncodingOptions>("encoding");
}
- private string GetHdHrIdFromChannelId(string channelId)
+ private static string GetHdHrIdFromChannelId(string channelId)
{
return channelId.Split('_')[1];
}
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs
index 0e84622bd..335fc4cb4 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs
@@ -37,10 +37,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{
var commands = new List<Tuple<string, string>>();
- if (!String.IsNullOrEmpty(_channel))
+ if (!string.IsNullOrEmpty(_channel))
commands.Add(Tuple.Create("channel", _channel));
- if (!String.IsNullOrEmpty(_program))
+ if (!string.IsNullOrEmpty(_program))
commands.Add(Tuple.Create("program", _program));
return commands;
}
@@ -61,11 +61,11 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{
var commands = new List<Tuple<string, string>>();
- if (!String.IsNullOrEmpty(_channel))
+ if (!string.IsNullOrEmpty(_channel))
{
if (!string.IsNullOrEmpty(_profile) && !string.Equals(_profile, "native", StringComparison.OrdinalIgnoreCase))
{
- commands.Add(Tuple.Create("vchannel", String.Format("{0} transcode={1}", _channel, _profile)));
+ commands.Add(Tuple.Create("vchannel", string.Format("{0} transcode={1}", _channel, _profile)));
}
else
{
@@ -123,7 +123,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
}
}
- private async Task<bool> CheckTunerAvailability(ISocket socket, IpAddressInfo remoteIp, int tuner, CancellationToken cancellationToken)
+ private static async Task<bool> CheckTunerAvailability(ISocket socket, IpAddressInfo remoteIp, int tuner, CancellationToken cancellationToken)
{
var ipEndPoint = new IpEndPointInfo(remoteIp, HdHomeRunPort);
@@ -164,7 +164,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
continue;
_activeTuner = i;
- var lockKeyString = String.Format("{0:d}", lockKeyValue);
+ var lockKeyString = string.Format("{0:d}", lockKeyValue);
var lockkeyMsg = CreateSetMessage(i, "lockkey", lockKeyString, null);
await tcpClient.SendToAsync(lockkeyMsg, 0, lockkeyMsg.Length, ipEndPoint, cancellationToken).ConfigureAwait(false);
var response = await tcpClient.ReceiveAsync(receiveBuffer, 0, receiveBuffer.Length, cancellationToken).ConfigureAwait(false);
@@ -188,7 +188,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
}
- var targetValue = String.Format("rtp://{0}:{1}", localIp, localPort);
+ var targetValue = string.Format("rtp://{0}:{1}", localIp, localPort);
var targetMsg = CreateSetMessage(i, "target", targetValue, lockKeyValue);
await tcpClient.SendToAsync(targetMsg, 0, targetMsg.Length, ipEndPoint, cancellationToken).ConfigureAwait(false);
@@ -262,7 +262,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
private static byte[] CreateGetMessage(int tuner, string name)
{
- var byteName = Encoding.UTF8.GetBytes(String.Format("/tuner{0}/{1}\0", tuner, name));
+ var byteName = Encoding.UTF8.GetBytes(string.Format("/tuner{0}/{1}\0", tuner, name));
int messageLength = byteName.Length + 10; // 4 bytes for header + 4 bytes for crc + 2 bytes for tag name and length
var message = new byte[messageLength];
@@ -280,10 +280,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
return message;
}
- private static byte[] CreateSetMessage(int tuner, String name, String value, uint? lockkey)
+ private static byte[] CreateSetMessage(int tuner, string name, string value, uint? lockkey)
{
- var byteName = Encoding.UTF8.GetBytes(String.Format("/tuner{0}/{1}\0", tuner, name));
- var byteValue = Encoding.UTF8.GetBytes(String.Format("{0}\0", value));
+ var byteName = Encoding.UTF8.GetBytes(string.Format("/tuner{0}/{1}\0", tuner, name));
+ var byteValue = Encoding.UTF8.GetBytes(string.Format("{0}\0", value));
int messageLength = byteName.Length + byteValue.Length + 12;
if (lockkey.HasValue)
@@ -360,7 +360,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
private static bool ParseReturnMessage(byte[] buf, int numBytes, out string returnVal)
{
- returnVal = String.Empty;
+ returnVal = string.Empty;
if (numBytes < 4)
return false;
@@ -411,7 +411,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
private class HdHomerunCrc
{
- private static UInt32[] crc_table = {
+ private static uint[] crc_table = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
@@ -477,7 +477,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d };
- public static UInt32 GetCrc32(byte[] bytes, int numBytes)
+ public static uint GetCrc32(byte[] bytes, int numBytes)
{
var hash = 0xffffffff;
for (var i = 0; i < numBytes; i++)
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs
index c781bccbb..1a33154f8 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -38,7 +38,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
EnableStreamSharing = true;
}
- private Socket CreateSocket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
+ private static Socket CreateSocket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
{
var socket = new Socket(addressFamily, SocketType.Stream, ProtocolType.Tcp);
@@ -144,7 +144,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
});
}
- private void Resolve(TaskCompletionSource<bool> openTaskCompletionSource)
+ private static void Resolve(TaskCompletionSource<bool> openTaskCompletionSource)
{
Task.Run(() =>
{
@@ -204,16 +204,16 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
public override async Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
{
if (buffer == null)
- throw new ArgumentNullException("buffer");
+ throw new ArgumentNullException(nameof(buffer));
if (offset + count < 0)
- throw new ArgumentOutOfRangeException("offset + count must not be negative", "offset+count");
+ throw new ArgumentOutOfRangeException(nameof(offset),"offset + count must not be negative");
if (offset + count > buffer.Length)
- throw new ArgumentException("offset + count must not be greater than the length of buffer", "offset+count");
+ throw new ArgumentException("offset + count must not be greater than the length of buffer");
if (disposed)
- throw new ObjectDisposedException(typeof(UdpClientStream).ToString());
+ throw new ObjectDisposedException(nameof(UdpClientStream));
// This will always receive a 1328 packet size (PacketSize + RtpHeaderSize)
// The RTP header will be stripped so see how many reads we need to make to fill the buffer.
@@ -238,16 +238,16 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
public override int Read(byte[] buffer, int offset, int count)
{
if (buffer == null)
- throw new ArgumentNullException("buffer");
+ throw new ArgumentNullException(nameof(buffer));
if (offset + count < 0)
throw new ArgumentOutOfRangeException("offset + count must not be negative", "offset+count");
if (offset + count > buffer.Length)
- throw new ArgumentException("offset + count must not be greater than the length of buffer", "offset+count");
+ throw new ArgumentException("offset + count must not be greater than the length of buffer");
if (disposed)
- throw new ObjectDisposedException(typeof(UdpClientStream).ToString());
+ throw new ObjectDisposedException(nameof(UdpClientStream));
// This will always receive a 1328 packet size (PacketSize + RtpHeaderSize)
// The RTP header will be stripped so see how many reads we need to make to fill the buffer.
@@ -274,49 +274,19 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
disposed = true;
}
- public override bool CanRead
- {
- get
- {
- throw new NotImplementedException();
- }
- }
+ public override bool CanRead => throw new NotImplementedException();
- public override bool CanSeek
- {
- get
- {
- throw new NotImplementedException();
- }
- }
+ public override bool CanSeek => throw new NotImplementedException();
- public override bool CanWrite
- {
- get
- {
- throw new NotImplementedException();
- }
- }
+ public override bool CanWrite => throw new NotImplementedException();
- public override long Length
- {
- get
- {
- throw new NotImplementedException();
- }
- }
+ public override long Length => throw new NotImplementedException();
public override long Position
{
- get
- {
- throw new NotImplementedException();
- }
+ get => throw new NotImplementedException();
- set
- {
- throw new NotImplementedException();
- }
+ set => throw new NotImplementedException();
}
public override void Flush()
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs
index 4a2b4ebb2..b55b02ddc 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs
@@ -217,13 +217,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
}
}
- protected virtual int EmptyReadLimit
- {
- get
- {
- return 1000;
- }
- }
+ protected virtual int EmptyReadLimit => 1000;
private void TrySeek(FileStream stream, long offset)
{
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs
index a54bd1613..ab8731c39 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs
@@ -39,15 +39,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
_mediaSourceManager = mediaSourceManager;
}
- public override string Type
- {
- get { return "m3u"; }
- }
+ public override string Type => "m3u";
- public virtual string Name
- {
- get { return "M3U Tuner"; }
- }
+ public virtual string Name => "M3U Tuner";
private string GetFullChannelIdPrefix(TunerHostInfo info)
{
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
index 208225c1e..f83f95802 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
@@ -251,7 +251,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
return numberString;
}
- private bool IsValidChannelNumber(string numberString)
+ private static bool IsValidChannelNumber(string numberString)
{
if (string.IsNullOrWhiteSpace(numberString) ||
string.Equals(numberString, "-1", StringComparison.OrdinalIgnoreCase) ||
@@ -269,7 +269,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
return true;
}
- private string GetChannelName(string extInf, Dictionary<string, string> attributes)
+ private static string GetChannelName(string extInf, Dictionary<string, string> attributes)
{
var nameParts = extInf.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
var nameInExtInf = nameParts.Length > 1 ? nameParts.Last().Trim() : null;
@@ -314,7 +314,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
return name;
}
- private Dictionary<string, string> ParseExtInf(string line, out string remaining)
+ private static Dictionary<string, string> ParseExtInf(string line, out string remaining)
{
var dict = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.cs
index c6de9d957..a2c47cd79 100644
--- a/Emby.Server.Implementations/Localization/LocalizationManager.cs
+++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Model.Extensions;
+using MediaBrowser.Model.Extensions;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Globalization;
@@ -165,13 +165,7 @@ namespace Emby.Server.Implementations.Localization
/// Gets the localization path.
/// </summary>
/// <value>The localization path.</value>
- public string LocalizationPath
- {
- get
- {
- return Path.Combine(_configurationManager.ApplicationPaths.ProgramDataPath, "localization");
- }
- }
+ public string LocalizationPath => Path.Combine(_configurationManager.ApplicationPaths.ProgramDataPath, "localization");
public string RemoveDiacritics(string text)
{
@@ -357,7 +351,7 @@ namespace Emby.Server.Implementations.Localization
{
if (string.IsNullOrEmpty(rating))
{
- throw new ArgumentNullException("rating");
+ throw new ArgumentNullException(nameof(rating));
}
if (_unratedValues.Contains(rating, StringComparer.OrdinalIgnoreCase))
@@ -452,7 +446,7 @@ namespace Emby.Server.Implementations.Localization
{
if (string.IsNullOrEmpty(culture))
{
- throw new ArgumentNullException("culture");
+ throw new ArgumentNullException(nameof(culture));
}
const string prefix = "Core";
@@ -465,7 +459,7 @@ namespace Emby.Server.Implementations.Localization
{
if (string.IsNullOrEmpty(culture))
{
- throw new ArgumentNullException("culture");
+ throw new ArgumentNullException(nameof(culture));
}
var dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
@@ -494,7 +488,7 @@ namespace Emby.Server.Implementations.Localization
}
}
- private string GetResourceFilename(string culture)
+ private static string GetResourceFilename(string culture)
{
var parts = culture.Split('-');
diff --git a/Emby.Server.Implementations/Localization/TextLocalizer.cs b/Emby.Server.Implementations/Localization/TextLocalizer.cs
index 5188a959e..6a6749935 100644
--- a/Emby.Server.Implementations/Localization/TextLocalizer.cs
+++ b/Emby.Server.Implementations/Localization/TextLocalizer.cs
@@ -12,13 +12,13 @@ namespace Emby.Server.Implementations.Localization
{
if (text == null)
{
- throw new ArgumentNullException("text");
+ throw new ArgumentNullException(nameof(text));
}
var chars = Normalize(text, NormalizationForm.FormD)
.Where(ch => CharUnicodeInfo.GetUnicodeCategory(ch) != UnicodeCategory.NonSpacingMark);
- return Normalize(String.Concat(chars), NormalizationForm.FormC);
+ return Normalize(string.Concat(chars), NormalizationForm.FormC);
}
private static string Normalize(string text, NormalizationForm form, bool stripStringOnFailure = true)
diff --git a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs
index 792ffb3c4..2db7b01db 100644
--- a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs
+++ b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Controller.Chapters;
+using MediaBrowser.Controller.Chapters;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
@@ -46,7 +46,7 @@ namespace Emby.Server.Implementations.MediaEncoder
/// Gets the chapter images data path.
/// </summary>
/// <value>The chapter images data path.</value>
- private string GetChapterImagesPath(BaseItem item)
+ private static string GetChapterImagesPath(BaseItem item)
{
return Path.Combine(item.GetInternalMetadataPath(), "chapters");
}
@@ -202,7 +202,7 @@ namespace Emby.Server.Implementations.MediaEncoder
return Path.Combine(GetChapterImagesPath(video), filename);
}
- private List<string> GetSavedChapterImages(Video video, IDirectoryService directoryService)
+ private static List<string> GetSavedChapterImages(Video video, IDirectoryService directoryService)
{
var path = GetChapterImagesPath(video);
diff --git a/Emby.Server.Implementations/Net/DisposableManagedObjectBase.cs b/Emby.Server.Implementations/Net/DisposableManagedObjectBase.cs
index b721e8a26..9d880b0c9 100644
--- a/Emby.Server.Implementations/Net/DisposableManagedObjectBase.cs
+++ b/Emby.Server.Implementations/Net/DisposableManagedObjectBase.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
namespace Emby.Server.Implementations.Net
{
@@ -16,15 +16,17 @@ namespace Emby.Server.Implementations.Net
/// <param name="disposing">True if managed objects should be disposed, if false, only unmanaged resources should be released.</param>
protected abstract void Dispose(bool disposing);
+
+ //TODO Remove and reimplement using the IsDisposed property directly.
/// <summary>
- /// Throws and <see cref="System.ObjectDisposedException"/> if the <see cref="IsDisposed"/> property is true.
+ /// Throws an <see cref="System.ObjectDisposedException"/> if the <see cref="IsDisposed"/> property is true.
/// </summary>
/// <seealso cref="IsDisposed"/>
/// <exception cref="System.ObjectDisposedException">Thrown if the <see cref="IsDisposed"/> property is true.</exception>
/// <seealso cref="Dispose()"/>
protected virtual void ThrowIfDisposed()
{
- if (this.IsDisposed) throw new ObjectDisposedException(this.GetType().FullName);
+ if (IsDisposed) throw new ObjectDisposedException(GetType().Name);
}
#endregion
diff --git a/Emby.Server.Implementations/Net/SocketFactory.cs b/Emby.Server.Implementations/Net/SocketFactory.cs
index 3f93e767f..5c406df68 100644
--- a/Emby.Server.Implementations/Net/SocketFactory.cs
+++ b/Emby.Server.Implementations/Net/SocketFactory.cs
@@ -23,7 +23,7 @@ namespace Emby.Server.Implementations.Net
{
if (logger == null)
{
- throw new ArgumentNullException("logger");
+ throw new ArgumentNullException(nameof(logger));
}
_logger = logger;
@@ -31,7 +31,7 @@ namespace Emby.Server.Implementations.Net
public ISocket CreateTcpSocket(IpAddressInfo remoteAddress, int remotePort)
{
- if (remotePort < 0) throw new ArgumentException("remotePort cannot be less than zero.", "remotePort");
+ if (remotePort < 0) throw new ArgumentException("remotePort cannot be less than zero.", nameof(remotePort));
var addressFamily = remoteAddress.AddressFamily == IpAddressFamily.InterNetwork
? AddressFamily.InterNetwork
@@ -67,7 +67,7 @@ namespace Emby.Server.Implementations.Net
/// <param name="localPort">An integer specifying the local port to bind the acceptSocket to.</param>
public ISocket CreateUdpSocket(int localPort)
{
- if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", "localPort");
+ if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", nameof(localPort));
var retVal = new Socket(AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Dgram, System.Net.Sockets.ProtocolType.Udp);
try
@@ -86,7 +86,7 @@ namespace Emby.Server.Implementations.Net
public ISocket CreateUdpBroadcastSocket(int localPort)
{
- if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", "localPort");
+ if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", nameof(localPort));
var retVal = new Socket(AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Dgram, System.Net.Sockets.ProtocolType.Udp);
try
@@ -111,7 +111,7 @@ namespace Emby.Server.Implementations.Net
/// <returns>An implementation of the <see cref="ISocket"/> interface used by RSSDP components to perform acceptSocket operations.</returns>
public ISocket CreateSsdpUdpSocket(IpAddressInfo localIpAddress, int localPort)
{
- if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", "localPort");
+ if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", nameof(localPort));
var retVal = new Socket(AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Dgram, System.Net.Sockets.ProtocolType.Udp);
try
@@ -142,10 +142,10 @@ namespace Emby.Server.Implementations.Net
/// <returns></returns>
public ISocket CreateUdpMulticastSocket(string ipAddress, int multicastTimeToLive, int localPort)
{
- if (ipAddress == null) throw new ArgumentNullException("ipAddress");
- if (ipAddress.Length == 0) throw new ArgumentException("ipAddress cannot be an empty string.", "ipAddress");
- if (multicastTimeToLive <= 0) throw new ArgumentException("multicastTimeToLive cannot be zero or less.", "multicastTimeToLive");
- if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", "localPort");
+ if (ipAddress == null) throw new ArgumentNullException(nameof(ipAddress));
+ if (ipAddress.Length == 0) throw new ArgumentException("ipAddress cannot be an empty string.", nameof(ipAddress));
+ if (multicastTimeToLive <= 0) throw new ArgumentException("multicastTimeToLive cannot be zero or less.", nameof(multicastTimeToLive));
+ if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", nameof(localPort));
var retVal = new Socket(AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Dgram, System.Net.Sockets.ProtocolType.Udp);
@@ -212,26 +212,18 @@ namespace Emby.Server.Implementations.Net
{
}
- public override bool CanRead
- {
- get { return true; }
- }
- public override bool CanSeek
- {
- get { return false; }
- }
- public override bool CanWrite
- {
- get { return true; }
- }
- public override long Length
- {
- get { throw new NotImplementedException(); }
- }
+ public override bool CanRead => true;
+
+ public override bool CanSeek => false;
+
+ public override bool CanWrite => true;
+
+ public override long Length => throw new NotImplementedException();
+
public override long Position
{
- get { throw new NotImplementedException(); }
- set { throw new NotImplementedException(); }
+ get => throw new NotImplementedException();
+ set => throw new NotImplementedException();
}
public override void Write(byte[] buffer, int offset, int count)
diff --git a/Emby.Server.Implementations/Net/UdpSocket.cs b/Emby.Server.Implementations/Net/UdpSocket.cs
index 523ca3752..8f0421b86 100644
--- a/Emby.Server.Implementations/Net/UdpSocket.cs
+++ b/Emby.Server.Implementations/Net/UdpSocket.cs
@@ -16,10 +16,7 @@ namespace Emby.Server.Implementations.Net
private Socket _Socket;
private int _LocalPort;
- public Socket Socket
- {
- get { return _Socket; }
- }
+ public Socket Socket => _Socket;
private readonly SocketAsyncEventArgs _receiveSocketAsyncEventArgs = new SocketAsyncEventArgs()
{
@@ -36,7 +33,7 @@ namespace Emby.Server.Implementations.Net
public UdpSocket(Socket socket, int localPort, IPAddress ip)
{
- if (socket == null) throw new ArgumentNullException("socket");
+ if (socket == null) throw new ArgumentNullException(nameof(socket));
_Socket = socket;
_LocalPort = localPort;
@@ -102,7 +99,7 @@ namespace Emby.Server.Implementations.Net
public UdpSocket(Socket socket, IpEndPointInfo endPoint)
{
- if (socket == null) throw new ArgumentNullException("socket");
+ if (socket == null) throw new ArgumentNullException(nameof(socket));
_Socket = socket;
_Socket.Connect(NetworkManager.ToIPEndPoint(endPoint));
diff --git a/Emby.Server.Implementations/Networking/IPNetwork/IPAddressCollection.cs b/Emby.Server.Implementations/Networking/IPNetwork/IPAddressCollection.cs
index 2b31a0a32..7fe6a8d3d 100644
--- a/Emby.Server.Implementations/Networking/IPNetwork/IPAddressCollection.cs
+++ b/Emby.Server.Implementations/Networking/IPNetwork/IPAddressCollection.cs
@@ -19,13 +19,7 @@ namespace System.Net
#region Count, Array, Enumerator
- public BigInteger Count
- {
- get
- {
- return this._ipnetwork.Total;
- }
- }
+ public BigInteger Count => this._ipnetwork.Total;
public IPAddress this[BigInteger i]
{
@@ -33,7 +27,7 @@ namespace System.Net
{
if (i >= this.Count)
{
- throw new ArgumentOutOfRangeException("i");
+ throw new ArgumentOutOfRangeException(nameof(i));
}
byte width = this._ipnetwork.AddressFamily == Sockets.AddressFamily.InterNetwork ? (byte)32 : (byte)128;
IPNetworkCollection ipn = this._ipnetwork.Subnet(width);
@@ -57,10 +51,7 @@ namespace System.Net
#region IEnumerator<IPNetwork> Members
- public IPAddress Current
- {
- get { return this[this._enumerator]; }
- }
+ public IPAddress Current => this[this._enumerator];
#endregion
@@ -76,10 +67,7 @@ namespace System.Net
#region IEnumerator Members
- object IEnumerator.Current
- {
- get { return this.Current; }
- }
+ object IEnumerator.Current => this.Current;
public bool MoveNext()
{
diff --git a/Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs b/Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs
index 8d0fb7997..ba9cfff55 100644
--- a/Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs
+++ b/Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs
@@ -41,44 +41,19 @@ namespace System.Net
/// <summary>
/// Network address
/// </summary>
- public IPAddress Network
- {
- get
- {
-
- return IPNetwork.ToIPAddress(this._network, this._family);
- }
- }
+ public IPAddress Network => IPNetwork.ToIPAddress(this._network, this._family);
/// <summary>
/// Address Family
/// </summary>
- public AddressFamily AddressFamily
- {
- get
- {
- return this._family;
- }
- }
+ public AddressFamily AddressFamily => this._family;
- private BigInteger _netmask
- {
- get
- {
- return IPNetwork.ToUint(this._cidr, this._family);
- }
- }
+ private BigInteger _netmask => IPNetwork.ToUint(this._cidr, this._family);
/// <summary>
/// Netmask
/// </summary>
- public IPAddress Netmask
- {
- get
- {
- return IPNetwork.ToIPAddress(this._netmask, this._family);
- }
- }
+ public IPAddress Netmask => IPNetwork.ToIPAddress(this._netmask, this._family);
private BigInteger _broadcast
{
@@ -171,13 +146,7 @@ namespace System.Net
/// <summary>
/// The CIDR netmask notation
/// </summary>
- public byte Cidr
- {
- get
- {
- return this._cidr;
- }
- }
+ public byte Cidr => this._cidr;
#endregion
@@ -195,7 +164,7 @@ namespace System.Net
int maxCidr = family == Sockets.AddressFamily.InterNetwork ? 32 : 128;
if (cidr > maxCidr)
{
- throw new ArgumentOutOfRangeException("cidr");
+ throw new ArgumentOutOfRangeException(nameof(cidr));
}
this._ipaddress = ipaddress;
@@ -427,7 +396,7 @@ namespace System.Net
{
if (tryParse == false)
{
- throw new ArgumentNullException("ipaddress");
+ throw new ArgumentNullException(nameof(ipaddress));
}
ipnetwork = null;
return;
@@ -437,7 +406,7 @@ namespace System.Net
{
if (tryParse == false)
{
- throw new ArgumentNullException("netmask");
+ throw new ArgumentNullException(nameof(netmask));
}
ipnetwork = null;
return;
@@ -477,7 +446,7 @@ namespace System.Net
{
if (tryParse == false)
{
- throw new ArgumentNullException("network");
+ throw new ArgumentNullException(nameof(network));
}
ipnetwork = null;
return;
@@ -538,7 +507,7 @@ namespace System.Net
{
if (tryParse == false)
{
- throw new ArgumentNullException("ipaddress");
+ throw new ArgumentNullException(nameof(ipaddress));
}
ipnetwork = null;
return;
@@ -548,7 +517,7 @@ namespace System.Net
{
if (tryParse == false)
{
- throw new ArgumentNullException("netmask");
+ throw new ArgumentNullException(nameof(netmask));
}
ipnetwork = null;
return;
@@ -596,7 +565,7 @@ namespace System.Net
{
if (tryParse == false)
{
- throw new ArgumentNullException("ipaddress");
+ throw new ArgumentNullException(nameof(ipaddress));
}
ipnetwork = null;
return;
@@ -680,7 +649,7 @@ namespace System.Net
{
if (tryParse == false)
{
- throw new ArgumentNullException("ipaddress");
+ throw new ArgumentNullException(nameof(ipaddress));
}
uintIpAddress = null;
return;
@@ -751,7 +720,7 @@ namespace System.Net
{
if (tryParse == false)
{
- throw new ArgumentOutOfRangeException("cidr");
+ throw new ArgumentOutOfRangeException(nameof(cidr));
}
uintNetmask = null;
return;
@@ -761,7 +730,7 @@ namespace System.Net
{
if (tryParse == false)
{
- throw new ArgumentOutOfRangeException("cidr");
+ throw new ArgumentOutOfRangeException(nameof(cidr));
}
uintNetmask = null;
return;
@@ -872,7 +841,7 @@ namespace System.Net
{
if (tryParse == false)
{
- throw new ArgumentNullException("netmask");
+ throw new ArgumentNullException(nameof(netmask));
}
cidr = null;
return;
@@ -976,7 +945,7 @@ namespace System.Net
{
if (tryParse == false)
{
- throw new ArgumentOutOfRangeException("cidr");
+ throw new ArgumentOutOfRangeException(nameof(cidr));
}
netmask = null;
return;
@@ -1042,7 +1011,7 @@ namespace System.Net
if (netmask == null)
{
- throw new ArgumentNullException("netmask");
+ throw new ArgumentNullException(nameof(netmask));
}
BigInteger uintNetmask = IPNetwork.ToBigInteger(netmask);
bool valid = IPNetwork.InternalValidNetmask(uintNetmask, netmask.AddressFamily);
@@ -1145,7 +1114,7 @@ namespace System.Net
if (ipaddress == null)
{
- throw new ArgumentNullException("ipaddress");
+ throw new ArgumentNullException(nameof(ipaddress));
}
if (AddressFamily != ipaddress.AddressFamily)
@@ -1174,7 +1143,7 @@ namespace System.Net
if (network2 == null)
{
- throw new ArgumentNullException("network2");
+ throw new ArgumentNullException(nameof(network2));
}
BigInteger uintNetwork = _network;
@@ -1203,7 +1172,7 @@ namespace System.Net
if (network2 == null)
{
- throw new ArgumentNullException("network2");
+ throw new ArgumentNullException(nameof(network2));
}
BigInteger uintNetwork = _network;
@@ -1242,37 +1211,19 @@ namespace System.Net
/// 10.0.0.0/8
/// </summary>
/// <returns></returns>
- public static IPNetwork IANA_ABLK_RESERVED1
- {
- get
- {
- return _iana_ablock_reserved.Value;
- }
- }
+ public static IPNetwork IANA_ABLK_RESERVED1 => _iana_ablock_reserved.Value;
/// <summary>
/// 172.12.0.0/12
/// </summary>
/// <returns></returns>
- public static IPNetwork IANA_BBLK_RESERVED1
- {
- get
- {
- return _iana_bblock_reserved.Value;
- }
- }
+ public static IPNetwork IANA_BBLK_RESERVED1 => _iana_bblock_reserved.Value;
/// <summary>
/// 192.168.0.0/16
/// </summary>
/// <returns></returns>
- public static IPNetwork IANA_CBLK_RESERVED1
- {
- get
- {
- return _iana_cblock_reserved.Value;
- }
- }
+ public static IPNetwork IANA_CBLK_RESERVED1 => _iana_cblock_reserved.Value;
/// <summary>
/// return true if ipaddress is contained in
@@ -1285,7 +1236,7 @@ namespace System.Net
if (ipaddress == null)
{
- throw new ArgumentNullException("ipaddress");
+ throw new ArgumentNullException(nameof(ipaddress));
}
return IPNetwork.IANA_ABLK_RESERVED1.Contains(ipaddress)
@@ -1356,7 +1307,7 @@ namespace System.Net
{
if (trySubnet == false)
{
- throw new ArgumentNullException("network");
+ throw new ArgumentNullException(nameof(network));
}
ipnetworkCollection = null;
return;
@@ -1367,7 +1318,7 @@ namespace System.Net
{
if (trySubnet == false)
{
- throw new ArgumentOutOfRangeException("cidr");
+ throw new ArgumentOutOfRangeException(nameof(cidr));
}
ipnetworkCollection = null;
return;
@@ -1438,7 +1389,7 @@ namespace System.Net
{
if (trySupernet == false)
{
- throw new ArgumentNullException("network1");
+ throw new ArgumentNullException(nameof(network1));
}
supernet = null;
return;
@@ -1448,7 +1399,7 @@ namespace System.Net
{
if (trySupernet == false)
{
- throw new ArgumentNullException("network2");
+ throw new ArgumentNullException(nameof(network2));
}
supernet = null;
return;
@@ -1492,7 +1443,7 @@ namespace System.Net
{
if (trySupernet == false)
{
- throw new ArgumentOutOfRangeException("network");
+ throw new ArgumentOutOfRangeException(nameof(trySupernet), "TrySupernet was false while the first and last networks are not adjacent.");
}
supernet = null;
return;
@@ -1536,8 +1487,7 @@ namespace System.Net
/// 192.168.0.0/24 + 192.168.1.0/24 = 192.168.0.0/23
/// 192.168.0.0/24 + 192.168.1.0/24 + 192.168.2.0/24 + 192.168.3.0/24 = 192.168.0.0/22
/// </summary>
- /// <param name="ipnetworks"></param>
- /// <param name="supernet"></param>
+ /// <param name="ipnetworks">The IP networks</param>
/// <returns></returns>
public static IPNetwork[] Supernet(IPNetwork[] ipnetworks)
{
@@ -1573,7 +1523,7 @@ namespace System.Net
{
if (trySupernet == false)
{
- throw new ArgumentNullException("ipnetworks");
+ throw new ArgumentNullException(nameof(ipnetworks));
}
supernet = null;
return false;
@@ -1684,12 +1634,12 @@ namespace System.Net
if (string.IsNullOrEmpty(start))
{
- throw new ArgumentNullException("start");
+ throw new ArgumentNullException(nameof(start));
}
if (string.IsNullOrEmpty(end))
{
- throw new ArgumentNullException("end");
+ throw new ArgumentNullException(nameof(end));
}
IPAddress startIP;
@@ -1750,7 +1700,7 @@ namespace System.Net
{
if (tryWide == false)
{
- throw new ArgumentNullException("ipnetworks");
+ throw new ArgumentNullException(nameof(ipnetworks));
}
ipnetwork = null;
return;
@@ -1973,7 +1923,7 @@ namespace System.Net
#region IComparable<IPNetwork> Members
- public static Int32 Compare(IPNetwork left, IPNetwork right)
+ public static int Compare(IPNetwork left, IPNetwork right)
{
// two null IPNetworks are equal
if (ReferenceEquals(left, null) && ReferenceEquals(right, null)) return 0;
@@ -1994,12 +1944,12 @@ namespace System.Net
return result;
}
- public Int32 CompareTo(IPNetwork other)
+ public int CompareTo(IPNetwork other)
{
return Compare(this, other);
}
- public Int32 CompareTo(Object obj)
+ public int CompareTo(object obj)
{
// null is at less
if (obj == null) return 1;
@@ -2012,7 +1962,7 @@ namespace System.Net
{
throw new ArgumentException(
"The supplied parameter is an invalid type. Please supply an IPNetwork type.",
- "obj");
+ nameof(obj));
}
// perform the comparision
@@ -2023,17 +1973,17 @@ namespace System.Net
#region IEquatable<IPNetwork> Members
- public static Boolean Equals(IPNetwork left, IPNetwork right)
+ public static bool Equals(IPNetwork left, IPNetwork right)
{
return Compare(left, right) == 0;
}
- public Boolean Equals(IPNetwork other)
+ public bool Equals(IPNetwork other)
{
return Equals(this, other);
}
- public override Boolean Equals(Object obj)
+ public override bool Equals(object obj)
{
return Equals(this, obj as IPNetwork);
}
@@ -2042,22 +1992,22 @@ namespace System.Net
#region Operators
- public static Boolean operator ==(IPNetwork left, IPNetwork right)
+ public static bool operator ==(IPNetwork left, IPNetwork right)
{
return Equals(left, right);
}
- public static Boolean operator !=(IPNetwork left, IPNetwork right)
+ public static bool operator !=(IPNetwork left, IPNetwork right)
{
return !Equals(left, right);
}
- public static Boolean operator <(IPNetwork left, IPNetwork right)
+ public static bool operator <(IPNetwork left, IPNetwork right)
{
return Compare(left, right) < 0;
}
- public static Boolean operator >(IPNetwork left, IPNetwork right)
+ public static bool operator >(IPNetwork left, IPNetwork right)
{
return Compare(left, right) > 0;
}
diff --git a/Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs b/Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs
index 35cff88dc..48d404124 100644
--- a/Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs
+++ b/Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs
@@ -11,22 +11,12 @@ namespace System.Net
private byte _cidrSubnet;
private IPNetwork _ipnetwork;
- private byte _cidr
- {
- get { return this._ipnetwork.Cidr; }
- }
- private BigInteger _broadcast
- {
- get { return IPNetwork.ToBigInteger(this._ipnetwork.Broadcast); }
- }
- private BigInteger _lastUsable
- {
- get { return IPNetwork.ToBigInteger(this._ipnetwork.LastUsable); }
- }
- private BigInteger _network
- {
- get { return IPNetwork.ToBigInteger(this._ipnetwork.Network); }
- }
+ private byte _cidr => this._ipnetwork.Cidr;
+
+ private BigInteger _broadcast => IPNetwork.ToBigInteger(this._ipnetwork.Broadcast);
+
+ private BigInteger _lastUsable => IPNetwork.ToBigInteger(this._ipnetwork.LastUsable);
+ private BigInteger _network => IPNetwork.ToBigInteger(this._ipnetwork.Network);
#if TRAVISCI
public
#else
@@ -38,7 +28,7 @@ namespace System.Net
int maxCidr = ipnetwork.AddressFamily == Sockets.AddressFamily.InterNetwork ? 32 : 128;
if (cidrSubnet > maxCidr)
{
- throw new ArgumentOutOfRangeException("cidrSubnet");
+ throw new ArgumentOutOfRangeException(nameof(cidrSubnet));
}
if (cidrSubnet < ipnetwork.Cidr)
@@ -68,7 +58,7 @@ namespace System.Net
{
if (i >= this.Count)
{
- throw new ArgumentOutOfRangeException("i");
+ throw new ArgumentOutOfRangeException(nameof(i));
}
BigInteger last = this._ipnetwork.AddressFamily == Sockets.AddressFamily.InterNetworkV6
@@ -96,10 +86,7 @@ namespace System.Net
#region IEnumerator<IPNetwork> Members
- public IPNetwork Current
- {
- get { return this[this._enumerator]; }
- }
+ public IPNetwork Current => this[this._enumerator];
#endregion
@@ -115,10 +102,7 @@ namespace System.Net
#region IEnumerator Members
- object IEnumerator.Current
- {
- get { return this.Current; }
- }
+ object IEnumerator.Current => this.Current;
public bool MoveNext()
{
diff --git a/Emby.Server.Implementations/Networking/NetworkManager.cs b/Emby.Server.Implementations/Networking/NetworkManager.cs
index 260d20e35..dbf89d7e1 100644
--- a/Emby.Server.Implementations/Networking/NetworkManager.cs
+++ b/Emby.Server.Implementations/Networking/NetworkManager.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
@@ -114,7 +114,7 @@ namespace Emby.Server.Implementations.Networking
.ToList();
}
- private bool FilterIpAddress(IPAddress address)
+ private static bool FilterIpAddress(IPAddress address)
{
var addressString = address.ToString();
@@ -228,7 +228,7 @@ namespace Emby.Server.Implementations.Networking
subnet_Test++;
}
- var subnet_Match = String.Join(".", unicastIPAddressInformation.Address.ToString().Split('.').Take(subnet_Test).ToArray());
+ var subnet_Match = string.Join(".", unicastIPAddressInformation.Address.ToString().Split('.').Take(subnet_Test).ToArray());
// TODO: Is this check necessary?
if (adapter.OperationalStatus == OperationalStatus.Up)
@@ -245,7 +245,7 @@ namespace Emby.Server.Implementations.Networking
}
}
- private bool Is172AddressPrivate(string endpoint)
+ private static bool Is172AddressPrivate(string endpoint)
{
for (var i = 16; i <= 31; i++)
{
@@ -268,7 +268,7 @@ namespace Emby.Server.Implementations.Networking
return IsAddressInSubnets(IPAddress.Parse(addressString), addressString, subnets);
}
- private bool IsAddressInSubnets(IPAddress address, string addressString, string[] subnets)
+ private static bool IsAddressInSubnets(IPAddress address, string addressString, string[] subnets)
{
foreach (var subnet in subnets)
{
@@ -296,7 +296,7 @@ namespace Emby.Server.Implementations.Networking
{
if (string.IsNullOrEmpty(endpoint))
{
- throw new ArgumentNullException("endpoint");
+ throw new ArgumentNullException(nameof(endpoint));
}
IPAddress address;
@@ -380,7 +380,7 @@ namespace Emby.Server.Implementations.Networking
return false;
}
- private Task<IPAddress[]> GetIpAddresses(string hostName)
+ private static Task<IPAddress[]> GetIpAddresses(string hostName)
{
return Dns.GetHostAddressesAsync(hostName);
}
@@ -436,7 +436,7 @@ namespace Emby.Server.Implementations.Networking
.ToList();
}
- private async Task<IEnumerable<IPAddress>> GetLocalIpAddressesFallback()
+ private static async Task<IEnumerable<IPAddress>> GetLocalIpAddressesFallback()
{
var host = await Dns.GetHostEntryAsync(Dns.GetHostName()).ConfigureAwait(false);
@@ -480,7 +480,7 @@ namespace Emby.Server.Implementations.Networking
return _macAddresses;
}
- private List<string> GetMacAddressesInternal()
+ private static List<string> GetMacAddressesInternal()
{
return NetworkInterface.GetAllNetworkInterfaces()
.Where(i => i.NetworkInterfaceType != NetworkInterfaceType.Loopback)
@@ -497,8 +497,9 @@ namespace Emby.Server.Implementations.Networking
return physicalAddress.ToString();
}
- catch (Exception ex)
+ catch (Exception)
{
+ //TODO Log exception.
return null;
}
})
@@ -526,7 +527,7 @@ namespace Emby.Server.Implementations.Networking
/// <exception cref="System.FormatException"></exception>
private static async Task<IPEndPoint> Parse(string endpointstring, int defaultport)
{
- if (String.IsNullOrEmpty(endpointstring)
+ if (string.IsNullOrEmpty(endpointstring)
|| endpointstring.Trim().Length == 0)
{
throw new ArgumentException("Endpoint descriptor may not be empty.");
@@ -536,7 +537,7 @@ namespace Emby.Server.Implementations.Networking
(defaultport < IPEndPoint.MinPort
|| defaultport > IPEndPoint.MaxPort))
{
- throw new ArgumentException(String.Format("Invalid default port '{0}'", defaultport));
+ throw new ArgumentException(string.Format("Invalid default port '{0}'", defaultport));
}
string[] values = endpointstring.Split(new char[] { ':' });
@@ -557,7 +558,7 @@ namespace Emby.Server.Implementations.Networking
//could [a:b:c]:d
if (values[0].StartsWith("[") && values[values.Length - 2].EndsWith("]"))
{
- string ipaddressstring = String.Join(":", values.Take(values.Length - 1).ToArray());
+ string ipaddressstring = string.Join(":", values.Take(values.Length - 1).ToArray());
ipaddy = IPAddress.Parse(ipaddressstring);
port = GetPort(values[values.Length - 1]);
}
@@ -569,11 +570,11 @@ namespace Emby.Server.Implementations.Networking
}
else
{
- throw new FormatException(String.Format("Invalid endpoint ipaddress '{0}'", endpointstring));
+ throw new FormatException(string.Format("Invalid endpoint ipaddress '{0}'", endpointstring));
}
if (port == -1)
- throw new ArgumentException(String.Format("No port specified: '{0}'", endpointstring));
+ throw new ArgumentException(string.Format("No port specified: '{0}'", endpointstring));
return new IPEndPoint(ipaddy, port);
}
@@ -590,11 +591,11 @@ namespace Emby.Server.Implementations.Networking
{
int port;
- if (!Int32.TryParse(p, out port)
+ if (!int.TryParse(p, out port)
|| port < IPEndPoint.MinPort
|| port > IPEndPoint.MaxPort)
{
- throw new FormatException(String.Format("Invalid end point port '{0}'", p));
+ throw new FormatException(string.Format("Invalid end point port '{0}'", p));
}
return port;
@@ -611,7 +612,7 @@ namespace Emby.Server.Implementations.Networking
var hosts = await Dns.GetHostAddressesAsync(p).ConfigureAwait(false);
if (hosts == null || hosts.Length == 0)
- throw new ArgumentException(String.Format("Host not found: {0}", p));
+ throw new ArgumentException(string.Format("Host not found: {0}", p));
return hosts[0];
}
diff --git a/Emby.Server.Implementations/Playlists/ManualPlaylistsFolder.cs b/Emby.Server.Implementations/Playlists/ManualPlaylistsFolder.cs
index 908fa65de..f2bc4c07d 100644
--- a/Emby.Server.Implementations/Playlists/ManualPlaylistsFolder.cs
+++ b/Emby.Server.Implementations/Playlists/ManualPlaylistsFolder.cs
@@ -25,28 +25,13 @@ namespace Emby.Server.Implementations.Playlists
}
[IgnoreDataMember]
- public override bool IsHidden
- {
- get
- {
- return true;
- }
- }
+ public override bool IsHidden => true;
[IgnoreDataMember]
- public override bool SupportsInheritedParentImages
- {
- get
- {
- return false;
- }
- }
+ public override bool SupportsInheritedParentImages => false;
[IgnoreDataMember]
- public override string CollectionType
- {
- get { return MediaBrowser.Model.Entities.CollectionType.Playlists; }
- }
+ public override string CollectionType => MediaBrowser.Model.Entities.CollectionType.Playlists;
protected override QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery query)
{
diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs
index 470711b9e..a5fa24fc8 100644
--- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs
+++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Playlists;
@@ -455,10 +455,17 @@ namespace Emby.Server.Implementations.Playlists
return MakeRelativePath(_fileSystem.GetDirectoryName(playlistPath), itemPath);
}
- private static String MakeRelativePath(string folderPath, string fileAbsolutePath)
+ private static string MakeRelativePath(string folderPath, string fileAbsolutePath)
{
- if (String.IsNullOrEmpty(folderPath)) throw new ArgumentNullException("folderPath");
- if (String.IsNullOrEmpty(fileAbsolutePath)) throw new ArgumentNullException("filePath");
+ if (string.IsNullOrEmpty(folderPath))
+ {
+ throw new ArgumentException("Folder path was null or empty.",nameof(folderPath));
+ }
+
+ if (string.IsNullOrEmpty(fileAbsolutePath))
+ {
+ throw new ArgumentException("File absolute path was null or empty.", nameof(fileAbsolutePath));
+ }
if (!folderPath.EndsWith(Path.DirectorySeparatorChar.ToString()))
{
@@ -471,7 +478,7 @@ namespace Emby.Server.Implementations.Playlists
if (folderUri.Scheme != fileAbsoluteUri.Scheme) { return fileAbsolutePath; } // path can't be made relative.
Uri relativeUri = folderUri.MakeRelativeUri(fileAbsoluteUri);
- String relativePath = Uri.UnescapeDataString(relativeUri.ToString());
+ string relativePath = Uri.UnescapeDataString(relativeUri.ToString());
if (fileAbsoluteUri.Scheme.Equals("file", StringComparison.CurrentCultureIgnoreCase))
{
diff --git a/Emby.Server.Implementations/Properties/AssemblyInfo.cs b/Emby.Server.Implementations/Properties/AssemblyInfo.cs
index 28ffcbac6..6cf7535d4 100644
--- a/Emby.Server.Implementations/Properties/AssemblyInfo.cs
+++ b/Emby.Server.Implementations/Properties/AssemblyInfo.cs
@@ -1,6 +1,5 @@
-using System.Resources;
using System.Reflection;
-using System.Runtime.CompilerServices;
+using System.Resources;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
@@ -9,20 +8,14 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Emby.Server.Implementations")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Emby.Server.Implementations")]
-[assembly: AssemblyCopyright("Copyright © 2016")]
+[assembly: AssemblyCompany("Jellyfin Project")]
+[assembly: AssemblyProduct("Jellyfin: The Free Software Media System")]
+[assembly: AssemblyCopyright("Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License Version 2")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")] \ No newline at end of file
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
diff --git a/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs b/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs
index 09dcc320a..904e93c56 100644
--- a/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs
@@ -70,10 +70,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
};
}
- public string Key
- {
- get { return "RefreshChapterImages"; }
- }
+ public string Key => "RefreshChapterImages";
/// <summary>
/// Returns the task to be executed
@@ -156,6 +153,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
}
catch (ObjectDisposedException)
{
+ //TODO Investigate and properly fix.
break;
}
}
@@ -165,33 +163,18 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// Gets the name of the task
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get
- {
- return "Chapter image extraction";
- }
- }
+ public string Name => "Chapter image extraction";
/// <summary>
/// Gets the description.
/// </summary>
/// <value>The description.</value>
- public string Description
- {
- get { return "Creates thumbnails for videos that have chapters."; }
- }
+ public string Description => "Creates thumbnails for videos that have chapters.";
/// <summary>
/// Gets the category.
/// </summary>
/// <value>The category.</value>
- public string Category
- {
- get
- {
- return "Library";
- }
- }
+ public string Category => "Library";
}
}
diff --git a/Emby.Server.Implementations/ScheduledTasks/PeopleValidationTask.cs b/Emby.Server.Implementations/ScheduledTasks/PeopleValidationTask.cs
index 02568fe3a..086688ae7 100644
--- a/Emby.Server.Implementations/ScheduledTasks/PeopleValidationTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/PeopleValidationTask.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Library;
using System;
using System.Collections.Generic;
using System.Threading;
@@ -24,6 +24,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// Initializes a new instance of the <see cref="PeopleValidationTask" /> class.
/// </summary>
/// <param name="libraryManager">The library manager.</param>
+ /// <param name="appHost">The server application host</param>
public PeopleValidationTask(ILibraryManager libraryManager, IServerApplicationHost appHost)
{
_libraryManager = libraryManager;
@@ -46,10 +47,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
};
}
- public string Key
- {
- get { return "RefreshPeople"; }
- }
+ public string Key => "RefreshPeople";
/// <summary>
/// Returns the task to be executed
@@ -66,30 +64,18 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// Gets the name of the task
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return "Refresh people"; }
- }
+ public string Name => "Refresh people";
/// <summary>
/// Gets the description.
/// </summary>
/// <value>The description.</value>
- public string Description
- {
- get { return "Updates metadata for actors and directors in your media library."; }
- }
+ public string Description => "Updates metadata for actors and directors in your media library.";
/// <summary>
/// Gets the category.
/// </summary>
/// <value>The category.</value>
- public string Category
- {
- get
- {
- return "Library";
- }
- }
+ public string Category => "Library";
}
}
diff --git a/Emby.Server.Implementations/ScheduledTasks/RefreshMediaLibraryTask.cs b/Emby.Server.Implementations/ScheduledTasks/RefreshMediaLibraryTask.cs
index fb07b8e99..b4a25c380 100644
--- a/Emby.Server.Implementations/ScheduledTasks/RefreshMediaLibraryTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/RefreshMediaLibraryTask.cs
@@ -62,35 +62,20 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return "Scan media library"; }
- }
+ public string Name => "Scan media library";
/// <summary>
/// Gets the description.
/// </summary>
/// <value>The description.</value>
- public string Description
- {
- get { return "Scans your media library and refreshes metatata based on configuration."; }
- }
+ public string Description => "Scans your media library and refreshes metatata based on configuration.";
/// <summary>
/// Gets the category.
/// </summary>
/// <value>The category.</value>
- public string Category
- {
- get
- {
- return "Library";
- }
- }
+ public string Category => "Library";
- public string Key
- {
- get { return "RefreshLibrary"; }
- }
+ public string Key => "RefreshLibrary";
}
}
diff --git a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
index 0bebca8fc..602eeb29b 100644
--- a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
@@ -78,23 +78,23 @@ namespace Emby.Server.Implementations.ScheduledTasks
{
if (scheduledTask == null)
{
- throw new ArgumentNullException("scheduledTask");
+ throw new ArgumentNullException(nameof(scheduledTask));
}
if (applicationPaths == null)
{
- throw new ArgumentNullException("applicationPaths");
+ throw new ArgumentNullException(nameof(applicationPaths));
}
if (taskManager == null)
{
- throw new ArgumentNullException("taskManager");
+ throw new ArgumentNullException(nameof(taskManager));
}
if (jsonSerializer == null)
{
- throw new ArgumentNullException("jsonSerializer");
+ throw new ArgumentNullException(nameof(jsonSerializer));
}
if (logger == null)
{
- throw new ArgumentNullException("logger");
+ throw new ArgumentNullException(nameof(logger));
}
ScheduledTask = scheduledTask;
@@ -171,28 +171,19 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ScheduledTask.Name; }
- }
+ public string Name => ScheduledTask.Name;
/// <summary>
/// Gets the description.
/// </summary>
/// <value>The description.</value>
- public string Description
- {
- get { return ScheduledTask.Description; }
- }
+ public string Description => ScheduledTask.Description;
/// <summary>
/// Gets the category.
/// </summary>
/// <value>The category.</value>
- public string Category
- {
- get { return ScheduledTask.Category; }
- }
+ public string Category => ScheduledTask.Category;
/// <summary>
/// Gets the current cancellation token
@@ -241,15 +232,12 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// <value>The triggers.</value>
private Tuple<TaskTriggerInfo, ITaskTrigger>[] InternalTriggers
{
- get
- {
- return _triggers;
- }
+ get => _triggers;
set
{
if (value == null)
{
- throw new ArgumentNullException("value");
+ throw new ArgumentNullException(nameof(value));
}
// Cleanup current triggers
@@ -280,7 +268,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
{
if (value == null)
{
- throw new ArgumentNullException("value");
+ throw new ArgumentNullException(nameof(value));
}
// This null check is not great, but is needed to handle bad user input, or user mucking with the config file incorrectly
@@ -730,7 +718,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
{
if (!info.TimeOfDayTicks.HasValue)
{
- throw new ArgumentNullException();
+ throw new ArgumentException("Info did not contain a TimeOfDayTicks.",nameof(info));
}
return new DailyTrigger
@@ -744,12 +732,12 @@ namespace Emby.Server.Implementations.ScheduledTasks
{
if (!info.TimeOfDayTicks.HasValue)
{
- throw new ArgumentNullException();
+ throw new ArgumentException("Info did not contain a TimeOfDayTicks.", nameof(info));
}
if (!info.DayOfWeek.HasValue)
{
- throw new ArgumentNullException();
+ throw new ArgumentException("Info did not contain a DayOfWeek.", nameof(info));
}
return new WeeklyTrigger
@@ -764,7 +752,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
{
if (!info.IntervalTicks.HasValue)
{
- throw new ArgumentNullException();
+ throw new ArgumentException("Info did not contain a IntervalTicks.", nameof(info));
}
return new IntervalTrigger
@@ -778,7 +766,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
{
if (!info.SystemEvent.HasValue)
{
- throw new ArgumentNullException();
+ throw new ArgumentException("Info did not contain a SystemEvent.", nameof(info));
}
return new SystemEventTrigger(_systemEvents)
diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs
index c60f59ce4..0eca40ec2 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs
@@ -162,54 +162,30 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
/// Gets the name of the task
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return "Cache file cleanup"; }
- }
+ public string Name => "Cache file cleanup";
- public string Key
- {
- get { return "DeleteCacheFiles"; }
- }
+ public string Key => "DeleteCacheFiles";
/// <summary>
/// Gets the description.
/// </summary>
/// <value>The description.</value>
- public string Description
- {
- get { return "Deletes cache files no longer needed by the system"; }
- }
+ public string Description => "Deletes cache files no longer needed by the system";
/// <summary>
/// Gets the category.
/// </summary>
/// <value>The category.</value>
- public string Category
- {
- get
- {
- return "Maintenance";
- }
- }
+ public string Category => "Maintenance";
/// <summary>
/// Gets a value indicating whether this instance is hidden.
/// </summary>
/// <value><c>true</c> if this instance is hidden; otherwise, <c>false</c>.</value>
- public bool IsHidden
- {
- get { return true; }
- }
+ public bool IsHidden => true;
- public bool IsEnabled
- {
- get { return true; }
- }
+ public bool IsEnabled => true;
- public bool IsLogged
- {
- get { return true; }
- }
+ public bool IsLogged => true;
}
}
diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs
index 95395f96c..b3f3b3c5d 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs
@@ -81,58 +81,34 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
return Task.CompletedTask;
}
- public string Key
- {
- get { return "CleanLogFiles"; }
- }
+ public string Key => "CleanLogFiles";
/// <summary>
/// Gets the name of the task
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return "Log file cleanup"; }
- }
+ public string Name => "Log file cleanup";
/// <summary>
/// Gets the description.
/// </summary>
/// <value>The description.</value>
- public string Description
- {
- get { return string.Format("Deletes log files that are more than {0} days old.", ConfigurationManager.CommonConfiguration.LogFileRetentionDays); }
- }
+ public string Description => string.Format("Deletes log files that are more than {0} days old.", ConfigurationManager.CommonConfiguration.LogFileRetentionDays);
/// <summary>
/// Gets the category.
/// </summary>
/// <value>The category.</value>
- public string Category
- {
- get
- {
- return "Maintenance";
- }
- }
+ public string Category => "Maintenance";
/// <summary>
/// Gets a value indicating whether this instance is hidden.
/// </summary>
/// <value><c>true</c> if this instance is hidden; otherwise, <c>false</c>.</value>
- public bool IsHidden
- {
- get { return true; }
- }
+ public bool IsHidden => true;
- public bool IsEnabled
- {
- get { return true; }
- }
+ public bool IsEnabled => true;
- public bool IsLogged
- {
- get { return true; }
- }
+ public bool IsLogged => true;
}
}
diff --git a/Emby.Server.Implementations/Security/AuthenticationRepository.cs b/Emby.Server.Implementations/Security/AuthenticationRepository.cs
index 228d511ce..2a6406f25 100644
--- a/Emby.Server.Implementations/Security/AuthenticationRepository.cs
+++ b/Emby.Server.Implementations/Security/AuthenticationRepository.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
@@ -91,7 +91,7 @@ namespace Emby.Server.Implementations.Security
{
if (info == null)
{
- throw new ArgumentNullException("info");
+ throw new ArgumentNullException(nameof(info));
}
using (WriteLock.Write())
@@ -126,7 +126,7 @@ namespace Emby.Server.Implementations.Security
{
if (info == null)
{
- throw new ArgumentNullException("entry");
+ throw new ArgumentNullException(nameof(info));
}
using (WriteLock.Write())
@@ -161,7 +161,7 @@ namespace Emby.Server.Implementations.Security
{
if (info == null)
{
- throw new ArgumentNullException("entry");
+ throw new ArgumentNullException(nameof(info));
}
using (WriteLock.Write())
@@ -183,7 +183,7 @@ namespace Emby.Server.Implementations.Security
private const string BaseSelectText = "select Tokens.Id, AccessToken, DeviceId, AppName, AppVersion, DeviceName, UserId, UserName, DateCreated, DateLastActivity, Devices.CustomName from Tokens left join Devices on Tokens.DeviceId=Devices.Id";
- private void BindAuthenticationQueryParams(AuthenticationInfoQuery query, IStatement statement)
+ private static void BindAuthenticationQueryParams(AuthenticationInfoQuery query, IStatement statement)
{
if (!string.IsNullOrEmpty(query.AccessToken))
{
@@ -205,7 +205,7 @@ namespace Emby.Server.Implementations.Security
{
if (query == null)
{
- throw new ArgumentNullException("query");
+ throw new ArgumentNullException(nameof(query));
}
var commandText = BaseSelectText;
@@ -306,7 +306,7 @@ namespace Emby.Server.Implementations.Security
}
}
- private AuthenticationInfo Get(IReadOnlyList<IResultSetValue> reader)
+ private static AuthenticationInfo Get(IReadOnlyList<IResultSetValue> reader)
{
var info = new AuthenticationInfo
{
@@ -397,7 +397,7 @@ namespace Emby.Server.Implementations.Security
{
if (options == null)
{
- throw new ArgumentNullException("options");
+ throw new ArgumentNullException(nameof(options));
}
using (WriteLock.Write())
diff --git a/Emby.Server.Implementations/Security/EncryptionManager.cs b/Emby.Server.Implementations/Security/EncryptionManager.cs
index 271b0bbdb..b99e00a67 100644
--- a/Emby.Server.Implementations/Security/EncryptionManager.cs
+++ b/Emby.Server.Implementations/Security/EncryptionManager.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Controller.Security;
+using MediaBrowser.Controller.Security;
using System;
using System.Text;
@@ -14,7 +14,10 @@ namespace Emby.Server.Implementations.Security
/// <exception cref="System.ArgumentNullException">value</exception>
public string EncryptString(string value)
{
- if (value == null) throw new ArgumentNullException("value");
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
return EncryptStringUniversal(value);
}
@@ -27,12 +30,15 @@ namespace Emby.Server.Implementations.Security
/// <exception cref="System.ArgumentNullException">value</exception>
public string DecryptString(string value)
{
- if (value == null) throw new ArgumentNullException("value");
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
return DecryptStringUniversal(value);
}
- private string EncryptStringUniversal(string value)
+ private static string EncryptStringUniversal(string value)
{
// Yes, this isn't good, but ProtectedData in mono is throwing exceptions, so use this for now
@@ -40,7 +46,7 @@ namespace Emby.Server.Implementations.Security
return Convert.ToBase64String(bytes);
}
- private string DecryptStringUniversal(string value)
+ private static string DecryptStringUniversal(string value)
{
// Yes, this isn't good, but ProtectedData in mono is throwing exceptions, so use this for now
diff --git a/Emby.Server.Implementations/Security/MBLicenseFile.cs b/Emby.Server.Implementations/Security/MBLicenseFile.cs
index 1810cbcd2..467ea16e2 100644
--- a/Emby.Server.Implementations/Security/MBLicenseFile.cs
+++ b/Emby.Server.Implementations/Security/MBLicenseFile.cs
@@ -19,7 +19,7 @@ namespace Emby.Server.Implementations.Security
public string RegKey
{
- get { return _regKey; }
+ get => _regKey;
set
{
_updateRecords.Clear();
@@ -27,13 +27,7 @@ namespace Emby.Server.Implementations.Security
}
}
- private string Filename
- {
- get
- {
- return Path.Combine(_appPaths.ConfigurationDirectoryPath, "mb.lic");
- }
- }
+ private string Filename => Path.Combine(_appPaths.ConfigurationDirectoryPath, "mb.lic");
private readonly ConcurrentDictionary<Guid, FeatureRegInfo> _updateRecords = new ConcurrentDictionary<Guid, FeatureRegInfo>();
private readonly object _fileLock = new object();
diff --git a/Emby.Server.Implementations/Security/PluginSecurityManager.cs b/Emby.Server.Implementations/Security/PluginSecurityManager.cs
index 2b1494c39..dc606f2b9 100644
--- a/Emby.Server.Implementations/Security/PluginSecurityManager.cs
+++ b/Emby.Server.Implementations/Security/PluginSecurityManager.cs
@@ -34,10 +34,7 @@ namespace Emby.Server.Implementations.Security
}
private MBLicenseFile _licenseFile;
- private MBLicenseFile LicenseFile
- {
- get { return _licenseFile ?? (_licenseFile = new MBLicenseFile(_appPaths, _fileSystem, _cryptographyProvider)); }
- }
+ private MBLicenseFile LicenseFile => _licenseFile ?? (_licenseFile = new MBLicenseFile(_appPaths, _fileSystem, _cryptographyProvider));
private readonly IHttpClient _httpClient;
private readonly IJsonSerializer _jsonSerializer;
@@ -55,7 +52,7 @@ namespace Emby.Server.Implementations.Security
{
if (httpClient == null)
{
- throw new ArgumentNullException("httpClient");
+ throw new ArgumentNullException(nameof(httpClient));
}
_appHost = appHost;
@@ -82,14 +79,8 @@ namespace Emby.Server.Implementations.Security
/// <value>The supporter key.</value>
public string SupporterKey
{
- get
- {
- return LicenseFile.RegKey;
- }
- set
- {
- throw new Exception("Please call UpdateSupporterKey");
- }
+ get => LicenseFile.RegKey;
+ set => throw new Exception("Please call UpdateSupporterKey");
}
public async Task UpdateSupporterKey(string newValue)
@@ -138,7 +129,7 @@ namespace Emby.Server.Implementations.Security
_logger.LogError(msg);
throw new ArgumentException(msg);
}
- if (!String.IsNullOrEmpty(reg.key))
+ if (!string.IsNullOrEmpty(reg.key))
{
await UpdateSupporterKey(reg.key).ConfigureAwait(false);
}
diff --git a/Emby.Server.Implementations/Serialization/JsonSerializer.cs b/Emby.Server.Implementations/Serialization/JsonSerializer.cs
index e28acd769..d4b6b2f43 100644
--- a/Emby.Server.Implementations/Serialization/JsonSerializer.cs
+++ b/Emby.Server.Implementations/Serialization/JsonSerializer.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.IO;
using MediaBrowser.Model.IO;
using Microsoft.Extensions.Logging;
@@ -32,12 +32,12 @@ namespace Emby.Common.Implementations.Serialization
{
if (obj == null)
{
- throw new ArgumentNullException("obj");
+ throw new ArgumentNullException(nameof(obj));
}
if (stream == null)
{
- throw new ArgumentNullException("stream");
+ throw new ArgumentNullException(nameof(stream));
}
ServiceStack.Text.JsonSerializer.SerializeToStream(obj, obj.GetType(), stream);
@@ -53,12 +53,12 @@ namespace Emby.Common.Implementations.Serialization
{
if (obj == null)
{
- throw new ArgumentNullException("obj");
+ throw new ArgumentNullException(nameof(obj));
}
if (string.IsNullOrEmpty(file))
{
- throw new ArgumentNullException("file");
+ throw new ArgumentNullException(nameof(file));
}
using (Stream stream = _fileSystem.GetFileStream(file, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
@@ -67,7 +67,7 @@ namespace Emby.Common.Implementations.Serialization
}
}
- private Stream OpenFile(string path)
+ private static Stream OpenFile(string path)
{
//_logger.LogDebug("Deserializing file {0}", path);
return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 131072);
@@ -84,12 +84,12 @@ namespace Emby.Common.Implementations.Serialization
{
if (type == null)
{
- throw new ArgumentNullException("type");
+ throw new ArgumentNullException(nameof(type));
}
if (string.IsNullOrEmpty(file))
{
- throw new ArgumentNullException("file");
+ throw new ArgumentNullException(nameof(file));
}
using (Stream stream = OpenFile(file))
@@ -110,7 +110,7 @@ namespace Emby.Common.Implementations.Serialization
{
if (string.IsNullOrEmpty(file))
{
- throw new ArgumentNullException("file");
+ throw new ArgumentNullException(nameof(file));
}
using (Stream stream = OpenFile(file))
@@ -130,7 +130,7 @@ namespace Emby.Common.Implementations.Serialization
{
if (stream == null)
{
- throw new ArgumentNullException("stream");
+ throw new ArgumentNullException(nameof(stream));
}
return ServiceStack.Text.JsonSerializer.DeserializeFromStream<T>(stream);
@@ -140,7 +140,7 @@ namespace Emby.Common.Implementations.Serialization
{
if (stream == null)
{
- throw new ArgumentNullException("stream");
+ throw new ArgumentNullException(nameof(stream));
}
@@ -158,7 +158,7 @@ namespace Emby.Common.Implementations.Serialization
{
if (string.IsNullOrEmpty(text))
{
- throw new ArgumentNullException("text");
+ throw new ArgumentNullException(nameof(text));
}
return ServiceStack.Text.JsonSerializer.DeserializeFromString<T>(text);
@@ -175,12 +175,12 @@ namespace Emby.Common.Implementations.Serialization
{
if (stream == null)
{
- throw new ArgumentNullException("stream");
+ throw new ArgumentNullException(nameof(stream));
}
if (type == null)
{
- throw new ArgumentNullException("type");
+ throw new ArgumentNullException(nameof(type));
}
return ServiceStack.Text.JsonSerializer.DeserializeFromStream(type, stream);
@@ -190,12 +190,12 @@ namespace Emby.Common.Implementations.Serialization
{
if (stream == null)
{
- throw new ArgumentNullException("stream");
+ throw new ArgumentNullException(nameof(stream));
}
if (type == null)
{
- throw new ArgumentNullException("type");
+ throw new ArgumentNullException(nameof(type));
}
using (var reader = new StreamReader(stream))
@@ -220,7 +220,7 @@ namespace Emby.Common.Implementations.Serialization
ServiceStack.Text.JsConfig<Guid>.SerializeFn = SerializeGuid;
}
- private string SerializeGuid(Guid guid)
+ private static string SerializeGuid(Guid guid)
{
if (guid.Equals(Guid.Empty))
{
@@ -241,12 +241,12 @@ namespace Emby.Common.Implementations.Serialization
{
if (string.IsNullOrEmpty(json))
{
- throw new ArgumentNullException("json");
+ throw new ArgumentNullException(nameof(json));
}
if (type == null)
{
- throw new ArgumentNullException("type");
+ throw new ArgumentNullException(nameof(type));
}
return ServiceStack.Text.JsonSerializer.DeserializeFromString(json, type);
@@ -262,7 +262,7 @@ namespace Emby.Common.Implementations.Serialization
{
if (obj == null)
{
- throw new ArgumentNullException("obj");
+ throw new ArgumentNullException(nameof(obj));
}
return ServiceStack.Text.JsonSerializer.SerializeToString(obj, obj.GetType());
diff --git a/Emby.Server.Implementations/ServerApplicationPaths.cs b/Emby.Server.Implementations/ServerApplicationPaths.cs
index 8a0f2671a..933b67291 100644
--- a/Emby.Server.Implementations/ServerApplicationPaths.cs
+++ b/Emby.Server.Implementations/ServerApplicationPaths.cs
@@ -30,174 +30,84 @@ namespace Emby.Server.Implementations
/// Gets the path to the base root media directory
/// </summary>
/// <value>The root folder path.</value>
- public string RootFolderPath
- {
- get
- {
- return Path.Combine(ProgramDataPath, "root");
- }
- }
+ public string RootFolderPath => Path.Combine(ProgramDataPath, "root");
/// <summary>
/// Gets the path to the default user view directory. Used if no specific user view is defined.
/// </summary>
/// <value>The default user views path.</value>
- public string DefaultUserViewsPath
- {
- get
- {
- return Path.Combine(RootFolderPath, "default");
- }
- }
+ public string DefaultUserViewsPath => Path.Combine(RootFolderPath, "default");
/// <summary>
/// Gets the path to localization data.
/// </summary>
/// <value>The localization path.</value>
- public string LocalizationPath
- {
- get
- {
- return Path.Combine(ProgramDataPath, "localization");
- }
- }
+ public string LocalizationPath => Path.Combine(ProgramDataPath, "localization");
/// <summary>
/// Gets the path to the People directory
/// </summary>
/// <value>The people path.</value>
- public string PeoplePath
- {
- get
- {
- return Path.Combine(InternalMetadataPath, "People");
- }
- }
+ public string PeoplePath => Path.Combine(InternalMetadataPath, "People");
- public string ArtistsPath
- {
- get
- {
- return Path.Combine(InternalMetadataPath, "artists");
- }
- }
+ public string ArtistsPath => Path.Combine(InternalMetadataPath, "artists");
/// <summary>
/// Gets the path to the Genre directory
/// </summary>
/// <value>The genre path.</value>
- public string GenrePath
- {
- get
- {
- return Path.Combine(InternalMetadataPath, "Genre");
- }
- }
+ public string GenrePath => Path.Combine(InternalMetadataPath, "Genre");
/// <summary>
/// Gets the path to the Genre directory
/// </summary>
/// <value>The genre path.</value>
- public string MusicGenrePath
- {
- get
- {
- return Path.Combine(InternalMetadataPath, "MusicGenre");
- }
- }
+ public string MusicGenrePath => Path.Combine(InternalMetadataPath, "MusicGenre");
/// <summary>
/// Gets the path to the Studio directory
/// </summary>
/// <value>The studio path.</value>
- public string StudioPath
- {
- get
- {
- return Path.Combine(InternalMetadataPath, "Studio");
- }
- }
+ public string StudioPath => Path.Combine(InternalMetadataPath, "Studio");
/// <summary>
/// Gets the path to the Year directory
/// </summary>
/// <value>The year path.</value>
- public string YearPath
- {
- get
- {
- return Path.Combine(InternalMetadataPath, "Year");
- }
- }
+ public string YearPath => Path.Combine(InternalMetadataPath, "Year");
/// <summary>
/// Gets the path to the General IBN directory
/// </summary>
/// <value>The general path.</value>
- public string GeneralPath
- {
- get
- {
- return Path.Combine(InternalMetadataPath, "general");
- }
- }
+ public string GeneralPath => Path.Combine(InternalMetadataPath, "general");
/// <summary>
/// Gets the path to the Ratings IBN directory
/// </summary>
/// <value>The ratings path.</value>
- public string RatingsPath
- {
- get
- {
- return Path.Combine(InternalMetadataPath, "ratings");
- }
- }
+ public string RatingsPath => Path.Combine(InternalMetadataPath, "ratings");
/// <summary>
/// Gets the media info images path.
/// </summary>
/// <value>The media info images path.</value>
- public string MediaInfoImagesPath
- {
- get
- {
- return Path.Combine(InternalMetadataPath, "mediainfo");
- }
- }
+ public string MediaInfoImagesPath => Path.Combine(InternalMetadataPath, "mediainfo");
/// <summary>
/// Gets the path to the user configuration directory
/// </summary>
/// <value>The user configuration directory path.</value>
- public string UserConfigurationDirectoryPath
- {
- get
- {
- return Path.Combine(ConfigurationDirectoryPath, "users");
- }
- }
+ public string UserConfigurationDirectoryPath => Path.Combine(ConfigurationDirectoryPath, "users");
private string _defaultTranscodingTempPath;
- public string DefaultTranscodingTempPath
- {
- get
- {
- return _defaultTranscodingTempPath ?? (_defaultTranscodingTempPath = Path.Combine(ProgramDataPath, "transcoding-temp"));
- }
- }
+ public string DefaultTranscodingTempPath => _defaultTranscodingTempPath ?? (_defaultTranscodingTempPath = Path.Combine(ProgramDataPath, "transcoding-temp"));
private string _transcodingTempPath;
public string TranscodingTempPath
{
- get
- {
- return _transcodingTempPath ?? (_transcodingTempPath = DefaultTranscodingTempPath);
- }
- set
- {
- _transcodingTempPath = value;
- }
+ get => _transcodingTempPath ?? (_transcodingTempPath = DefaultTranscodingTempPath);
+ set => _transcodingTempPath = value;
}
public string GetTranscodingTempPath()
@@ -230,35 +140,16 @@ namespace Emby.Server.Implementations
/// Gets the game genre path.
/// </summary>
/// <value>The game genre path.</value>
- public string GameGenrePath
- {
- get
- {
- return Path.Combine(InternalMetadataPath, "GameGenre");
- }
- }
+ public string GameGenrePath => Path.Combine(InternalMetadataPath, "GameGenre");
private string _internalMetadataPath;
public string InternalMetadataPath
{
- get
- {
- return _internalMetadataPath ?? (_internalMetadataPath = Path.Combine(DataPath, "metadata"));
- }
- set
- {
- _internalMetadataPath = value;
- }
+ get => _internalMetadataPath ?? (_internalMetadataPath = Path.Combine(DataPath, "metadata"));
+ set => _internalMetadataPath = value;
}
private const string _virtualInternalMetadataPath = "%MetadataPath%";
- public string VirtualInternalMetadataPath
- {
- get
- {
- return _virtualInternalMetadataPath;
- }
- }
-
+ public string VirtualInternalMetadataPath => _virtualInternalMetadataPath;
}
}
diff --git a/Emby.Server.Implementations/Services/HttpResult.cs b/Emby.Server.Implementations/Services/HttpResult.cs
index 91314c15a..7ce41a368 100644
--- a/Emby.Server.Implementations/Services/HttpResult.cs
+++ b/Emby.Server.Implementations/Services/HttpResult.cs
@@ -32,8 +32,8 @@ namespace Emby.Server.Implementations.Services
public HttpStatusCode StatusCode
{
- get { return (HttpStatusCode)Status; }
- set { Status = (int)value; }
+ get => (HttpStatusCode)Status;
+ set => Status = (int)value;
}
public IRequest RequestContext { get; set; }
diff --git a/Emby.Server.Implementations/Services/ServicePath.cs b/Emby.Server.Implementations/Services/ServicePath.cs
index ac2af3eaf..c38ba13d5 100644
--- a/Emby.Server.Implementations/Services/ServicePath.cs
+++ b/Emby.Server.Implementations/Services/ServicePath.cs
@@ -50,7 +50,7 @@ namespace Emby.Server.Implementations.Services
public Type ServiceType { get; private set; }
- public string Path { get { return this.restPath; } }
+ public string Path => this.restPath;
public string Summary { get; private set; }
public string Description { get; private set; }
@@ -58,10 +58,7 @@ namespace Emby.Server.Implementations.Services
public int Priority { get; set; } //passed back to RouteAttribute
- public IEnumerable<string> PathVariables
- {
- get { return this.variablesNames.Where(e => !string.IsNullOrWhiteSpace(e)); }
- }
+ public IEnumerable<string> PathVariables => this.variablesNames.Where(e => !string.IsNullOrWhiteSpace(e));
public static string[] GetPathPartsForMatching(string pathInfo)
{
@@ -117,8 +114,9 @@ namespace Emby.Server.Implementations.Services
var hasSeparators = new List<bool>();
foreach (var component in this.restPath.Split(PathSeperatorChar))
{
- if (String.IsNullOrEmpty(component)) continue;
+ if (string.IsNullOrEmpty(component)) continue;
+
if (StringContains(component, VariablePrefix)
&& component.IndexOf(ComponentSeperator) != -1)
{
@@ -420,10 +418,10 @@ namespace Emby.Server.Implementations.Services
return pathIx == withPathInfoParts.Length;
}
- private bool LiteralsEqual(string str1, string str2)
+ private static bool LiteralsEqual(string str1, string str2)
{
// Most cases
- if (String.Equals(str1, str2, StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(str1, str2, StringComparison.OrdinalIgnoreCase))
{
return true;
}
@@ -433,7 +431,7 @@ namespace Emby.Server.Implementations.Services
str2 = str2.ToUpperInvariant();
// Invariant IgnoreCase would probably be better but it's not available in PCL
- return String.Equals(str1, str2, StringComparison.CurrentCultureIgnoreCase);
+ return string.Equals(str1, str2, StringComparison.CurrentCultureIgnoreCase);
}
private bool ExplodeComponents(ref string[] withPathInfoParts)
@@ -442,7 +440,7 @@ namespace Emby.Server.Implementations.Services
for (var i = 0; i < withPathInfoParts.Length; i++)
{
var component = withPathInfoParts[i];
- if (String.IsNullOrEmpty(component)) continue;
+ if (string.IsNullOrEmpty(component)) continue;
if (this.PathComponentsCount != this.TotalComponentsCount
&& this.componentsWithSeparators[i])
@@ -473,7 +471,7 @@ namespace Emby.Server.Implementations.Services
&& requestComponents.Length >= this.TotalComponentsCount - this.wildcardCount;
if (!isValidWildCardPath)
- throw new ArgumentException(String.Format(
+ throw new ArgumentException(string.Format(
"Path Mismatch: Request Path '{0}' has invalid number of components compared to: '{1}'",
pathInfo, this.restPath));
}
@@ -492,7 +490,7 @@ namespace Emby.Server.Implementations.Services
string propertyNameOnRequest;
if (!this.propertyNamesMap.TryGetValue(variableName.ToLower(), out propertyNameOnRequest))
{
- if (String.Equals("ignore", variableName, StringComparison.OrdinalIgnoreCase))
+ if (string.Equals("ignore", variableName, StringComparison.OrdinalIgnoreCase))
{
pathIx++;
continue;
@@ -522,12 +520,12 @@ namespace Emby.Server.Implementations.Services
// hits a match for the next element in the definition (which must be a literal)
// It may consume 0 or more path parts
var stopLiteral = i == this.TotalComponentsCount - 1 ? null : this.literalsToMatch[i + 1];
- if (!String.Equals(requestComponents[pathIx], stopLiteral, StringComparison.OrdinalIgnoreCase))
+ if (!string.Equals(requestComponents[pathIx], stopLiteral, StringComparison.OrdinalIgnoreCase))
{
var sb = new StringBuilder();
sb.Append(value);
pathIx++;
- while (!String.Equals(requestComponents[pathIx], stopLiteral, StringComparison.OrdinalIgnoreCase))
+ while (!string.Equals(requestComponents[pathIx], stopLiteral, StringComparison.OrdinalIgnoreCase))
{
sb.Append(PathSeperatorChar + requestComponents[pathIx++]);
}
diff --git a/Emby.Server.Implementations/Session/HttpSessionController.cs b/Emby.Server.Implementations/Session/HttpSessionController.cs
index ff9b3fefc..c61e2aff4 100644
--- a/Emby.Server.Implementations/Session/HttpSessionController.cs
+++ b/Emby.Server.Implementations/Session/HttpSessionController.cs
@@ -36,26 +36,11 @@ namespace Emby.Server.Implementations.Session
_sessionManager = sessionManager;
}
- private string PostUrl
- {
- get
- {
- return string.Format("http://{0}{1}", Session.RemoteEndPoint, _postUrl);
- }
- }
+ private string PostUrl => string.Format("http://{0}{1}", Session.RemoteEndPoint, _postUrl);
- public bool IsSessionActive
- {
- get
- {
- return (DateTime.UtcNow - Session.LastActivityDate).TotalMinutes <= 5;
- }
- }
+ public bool IsSessionActive => (DateTime.UtcNow - Session.LastActivityDate).TotalMinutes <= 5;
- public bool SupportsMediaControl
- {
- get { return true; }
- }
+ public bool SupportsMediaControl => true;
private Task SendMessage(string name, string messageId, CancellationToken cancellationToken)
{
@@ -164,7 +149,7 @@ namespace Emby.Server.Implementations.Session
{
if (typeof(T) == typeof(string))
{
- var str = data as String;
+ var str = data as string;
if (!string.IsNullOrEmpty(str))
{
options.RequestContent = str;
@@ -189,7 +174,7 @@ namespace Emby.Server.Implementations.Session
}
}
- private string ToQueryString(Dictionary<string, string> nvc)
+ private static string ToQueryString(Dictionary<string, string> nvc)
{
var array = (from item in nvc
select string.Format("{0}={1}", WebUtility.UrlEncode(item.Key), WebUtility.UrlEncode(item.Value)))
diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs
index 7321e9f86..4e444ac01 100644
--- a/Emby.Server.Implementations/Session/SessionManager.cs
+++ b/Emby.Server.Implementations/Session/SessionManager.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Common.Events;
+using MediaBrowser.Common.Events;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
@@ -148,10 +148,7 @@ namespace Emby.Server.Implementations.Session
/// Gets all connections.
/// </summary>
/// <value>All connections.</value>
- public IEnumerable<SessionInfo> Sessions
- {
- get { return _activeConnections.Values.OrderByDescending(c => c.LastActivityDate).ToList(); }
- }
+ public IEnumerable<SessionInfo> Sessions => _activeConnections.Values.OrderByDescending(c => c.LastActivityDate).ToList();
private void OnSessionStarted(SessionInfo info)
{
@@ -218,15 +215,15 @@ namespace Emby.Server.Implementations.Session
if (string.IsNullOrEmpty(appName))
{
- throw new ArgumentNullException("appName");
+ throw new ArgumentNullException(nameof(appName));
}
if (string.IsNullOrEmpty(appVersion))
{
- throw new ArgumentNullException("appVersion");
+ throw new ArgumentNullException(nameof(appVersion));
}
if (string.IsNullOrEmpty(deviceId))
{
- throw new ArgumentNullException("deviceId");
+ throw new ArgumentNullException(nameof(deviceId));
}
var activityDate = DateTime.UtcNow;
@@ -381,7 +378,7 @@ namespace Emby.Server.Implementations.Session
}
}
- private string GetSessionKey(string appName, string deviceId)
+ private static string GetSessionKey(string appName, string deviceId)
{
return appName + deviceId;
}
@@ -402,7 +399,7 @@ namespace Emby.Server.Implementations.Session
if (string.IsNullOrEmpty(deviceId))
{
- throw new ArgumentNullException("deviceId");
+ throw new ArgumentNullException(nameof(deviceId));
}
var key = GetSessionKey(appName, deviceId);
@@ -582,7 +579,7 @@ namespace Emby.Server.Implementations.Session
if (info == null)
{
- throw new ArgumentNullException("info");
+ throw new ArgumentNullException(nameof(info));
}
var session = GetSession(info.SessionId);
@@ -631,7 +628,7 @@ namespace Emby.Server.Implementations.Session
/// <summary>
/// Called when [playback start].
/// </summary>
- /// <param name="userId">The user identifier.</param>
+ /// <param name="user">The user object.</param>
/// <param name="item">The item.</param>
private void OnPlaybackStart(User user, BaseItem item)
{
@@ -669,7 +666,7 @@ namespace Emby.Server.Implementations.Session
if (info == null)
{
- throw new ArgumentNullException("info");
+ throw new ArgumentNullException(nameof(info));
}
var session = GetSession(info.SessionId);
@@ -742,7 +739,7 @@ namespace Emby.Server.Implementations.Session
}
- private bool UpdatePlaybackSettings(User user, PlaybackProgressInfo info, UserItemData data)
+ private static bool UpdatePlaybackSettings(User user, PlaybackProgressInfo info, UserItemData data)
{
var changed = false;
@@ -796,12 +793,12 @@ namespace Emby.Server.Implementations.Session
if (info == null)
{
- throw new ArgumentNullException("info");
+ throw new ArgumentNullException(nameof(info));
}
if (info.PositionTicks.HasValue && info.PositionTicks.Value < 0)
{
- throw new ArgumentOutOfRangeException("positionTicks");
+ throw new ArgumentOutOfRangeException(nameof(info),"The PlaybackStopInfo's PositionTicks was negative.");
}
var session = GetSession(info.SessionId);
@@ -993,7 +990,7 @@ namespace Emby.Server.Implementations.Session
return SendMessageToSession(session, "GeneralCommand", command, cancellationToken);
}
- private async Task SendMessageToSession<T>(SessionInfo session, string name, T data, CancellationToken cancellationToken)
+ private static async Task SendMessageToSession<T>(SessionInfo session, string name, T data, CancellationToken cancellationToken)
{
var controllers = session.SessionControllers.ToArray();
var messageId = Guid.NewGuid().ToString("N");
@@ -1192,11 +1189,11 @@ namespace Emby.Server.Implementations.Session
{
if (session == null)
{
- throw new ArgumentNullException("session");
+ throw new ArgumentNullException(nameof(session));
}
if (controllingSession == null)
{
- throw new ArgumentNullException("controllingSession");
+ throw new ArgumentNullException(nameof(controllingSession));
}
}
@@ -1490,7 +1487,7 @@ namespace Emby.Server.Implementations.Session
if (string.IsNullOrEmpty(accessToken))
{
- throw new ArgumentNullException("accessToken");
+ throw new ArgumentNullException(nameof(accessToken));
}
var existing = _authRepo.Get(new AuthenticationInfoQuery
@@ -1611,7 +1608,7 @@ namespace Emby.Server.Implementations.Session
{
if (item == null)
{
- throw new ArgumentNullException("item");
+ throw new ArgumentNullException(nameof(item));
}
var dtoOptions = _itemInfoDtoOptions;
@@ -1684,7 +1681,7 @@ namespace Emby.Server.Implementations.Session
{
if (string.IsNullOrEmpty(itemId))
{
- throw new ArgumentNullException("itemId");
+ throw new ArgumentNullException(nameof(itemId));
}
//var item = _libraryManager.GetItemById(new Guid(itemId));
@@ -1726,7 +1723,7 @@ namespace Emby.Server.Implementations.Session
{
if (info == null)
{
- throw new ArgumentNullException("info");
+ throw new ArgumentNullException(nameof(info));
}
var user = info.UserId.Equals(Guid.Empty)
diff --git a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs
index 3bb022b32..116e455cf 100644
--- a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs
+++ b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Controller.Net;
+using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Events;
using Microsoft.Extensions.Logging;
@@ -43,7 +43,6 @@ namespace Emby.Server.Implementations.Session
/// <param name="loggerFactory">The logger factory.</param>
/// <param name="json">The json.</param>
/// <param name="httpServer">The HTTP server.</param>
- /// <param name="serverManager">The server manager.</param>
public SessionWebSocketListener(ISessionManager sessionManager, ILoggerFactory loggerFactory, IJsonSerializer json, IHttpServer httpServer)
{
_sessionManager = sessionManager;
@@ -71,7 +70,7 @@ namespace Emby.Server.Implementations.Session
{
if (queryString == null)
{
- throw new ArgumentNullException("queryString");
+ throw new ArgumentNullException(nameof(queryString));
}
var token = queryString["api_key"];
diff --git a/Emby.Server.Implementations/Session/WebSocketController.cs b/Emby.Server.Implementations/Session/WebSocketController.cs
index bdae5cf8f..ed34f8721 100644
--- a/Emby.Server.Implementations/Session/WebSocketController.cs
+++ b/Emby.Server.Implementations/Session/WebSocketController.cs
@@ -31,23 +31,11 @@ namespace Emby.Server.Implementations.Session
Sockets = new List<IWebSocketConnection>();
}
- private bool HasOpenSockets
- {
- get { return GetActiveSockets().Any(); }
- }
+ private bool HasOpenSockets => GetActiveSockets().Any();
- public bool SupportsMediaControl
- {
- get { return HasOpenSockets; }
- }
+ public bool SupportsMediaControl => HasOpenSockets;
- public bool IsSessionActive
- {
- get
- {
- return HasOpenSockets;
- }
- }
+ public bool IsSessionActive => HasOpenSockets;
private IEnumerable<IWebSocketConnection> GetActiveSockets()
{
diff --git a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs
index 494668cb9..1b2974c27 100644
--- a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs
+++ b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
@@ -16,6 +16,16 @@ namespace Emby.Server.Implementations.Sorting
/// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y)
{
+ if (x == null)
+ {
+ throw new ArgumentNullException(nameof(x));
+ }
+
+ if (y == null)
+ {
+ throw new ArgumentNullException(nameof(y));
+ }
+
if (x.PremiereDate.HasValue && y.PremiereDate.HasValue)
{
var val = DateTime.Compare(x.PremiereDate.Value, y.PremiereDate.Value);
@@ -70,7 +80,7 @@ namespace Emby.Server.Implementations.Sorting
return CompareEpisodeToSpecial(y, x) * -1;
}
- private int CompareEpisodeToSpecial(Episode x, Episode y)
+ private static int CompareEpisodeToSpecial(Episode x, Episode y)
{
// http://thetvdb.com/wiki/index.php?title=Special_Episodes
@@ -119,7 +129,7 @@ namespace Emby.Server.Implementations.Sorting
return GetSpecialCompareValue(x).CompareTo(GetSpecialCompareValue(y));
}
- private int GetSpecialCompareValue(Episode item)
+ private static int GetSpecialCompareValue(Episode item)
{
// First sort by season number
// Since there are three sort orders, pad with 9 digits (3 for each, figure 1000 episode buffer should be enough)
@@ -140,7 +150,7 @@ namespace Emby.Server.Implementations.Sorting
return val;
}
- private int CompareEpisodes(Episode x, Episode y)
+ private static int CompareEpisodes(Episode x, Episode y)
{
var xValue = (x.ParentIndexNumber ?? -1) * 1000 + (x.IndexNumber ?? -1);
var yValue = (y.ParentIndexNumber ?? -1) * 1000 + (y.IndexNumber ?? -1);
@@ -152,9 +162,6 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.AiredEpisodeOrder; }
- }
+ public string Name => ItemSortBy.AiredEpisodeOrder;
}
}
diff --git a/Emby.Server.Implementations/Sorting/AlbumArtistComparer.cs b/Emby.Server.Implementations/Sorting/AlbumArtistComparer.cs
index cd3834080..df64d816f 100644
--- a/Emby.Server.Implementations/Sorting/AlbumArtistComparer.cs
+++ b/Emby.Server.Implementations/Sorting/AlbumArtistComparer.cs
@@ -1,4 +1,4 @@
-using System.Linq;
+using System.Linq;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Sorting;
@@ -28,7 +28,7 @@ namespace Emby.Server.Implementations.Sorting
/// </summary>
/// <param name="x">The x.</param>
/// <returns>System.String.</returns>
- private string GetValue(BaseItem x)
+ private static string GetValue(BaseItem x)
{
var audio = x as IHasAlbumArtist;
@@ -39,9 +39,6 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.AlbumArtist; }
- }
+ public string Name => ItemSortBy.AlbumArtist;
}
}
diff --git a/Emby.Server.Implementations/Sorting/AlbumComparer.cs b/Emby.Server.Implementations/Sorting/AlbumComparer.cs
index 68f5f173e..dda1c5478 100644
--- a/Emby.Server.Implementations/Sorting/AlbumComparer.cs
+++ b/Emby.Server.Implementations/Sorting/AlbumComparer.cs
@@ -27,7 +27,7 @@ namespace Emby.Server.Implementations.Sorting
/// </summary>
/// <param name="x">The x.</param>
/// <returns>System.String.</returns>
- private string GetValue(BaseItem x)
+ private static string GetValue(BaseItem x)
{
var audio = x as Audio;
@@ -38,9 +38,6 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.Album; }
- }
+ public string Name => ItemSortBy.Album;
}
}
diff --git a/Emby.Server.Implementations/Sorting/ArtistComparer.cs b/Emby.Server.Implementations/Sorting/ArtistComparer.cs
index 616aff673..b0f0549e3 100644
--- a/Emby.Server.Implementations/Sorting/ArtistComparer.cs
+++ b/Emby.Server.Implementations/Sorting/ArtistComparer.cs
@@ -27,7 +27,7 @@ namespace Emby.Server.Implementations.Sorting
/// </summary>
/// <param name="x">The x.</param>
/// <returns>System.String.</returns>
- private string GetValue(BaseItem x)
+ private static string GetValue(BaseItem x)
{
var audio = x as Audio;
@@ -43,9 +43,6 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.Artist; }
- }
+ public string Name => ItemSortBy.Artist;
}
}
diff --git a/Emby.Server.Implementations/Sorting/CommunityRatingComparer.cs b/Emby.Server.Implementations/Sorting/CommunityRatingComparer.cs
index 396bbbdb9..994759171 100644
--- a/Emby.Server.Implementations/Sorting/CommunityRatingComparer.cs
+++ b/Emby.Server.Implementations/Sorting/CommunityRatingComparer.cs
@@ -1,6 +1,7 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
+using System;
namespace Emby.Server.Implementations.Sorting
{
@@ -14,6 +15,12 @@ namespace Emby.Server.Implementations.Sorting
/// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y)
{
+ if (x == null)
+ throw new ArgumentNullException(nameof(x));
+
+ if (y == null)
+ throw new ArgumentNullException(nameof(y));
+
return (x.CommunityRating ?? 0).CompareTo(y.CommunityRating ?? 0);
}
@@ -21,9 +28,6 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.CommunityRating; }
- }
+ public string Name => ItemSortBy.CommunityRating;
}
}
diff --git a/Emby.Server.Implementations/Sorting/CriticRatingComparer.cs b/Emby.Server.Implementations/Sorting/CriticRatingComparer.cs
index 877dbfcc1..5c4aeaf86 100644
--- a/Emby.Server.Implementations/Sorting/CriticRatingComparer.cs
+++ b/Emby.Server.Implementations/Sorting/CriticRatingComparer.cs
@@ -20,7 +20,7 @@ namespace Emby.Server.Implementations.Sorting
return GetValue(x).CompareTo(GetValue(y));
}
- private float GetValue(BaseItem x)
+ private static float GetValue(BaseItem x)
{
return x.CriticRating ?? 0;
}
@@ -29,9 +29,6 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.CriticRating; }
- }
+ public string Name => ItemSortBy.CriticRating;
}
}
diff --git a/Emby.Server.Implementations/Sorting/DateCreatedComparer.cs b/Emby.Server.Implementations/Sorting/DateCreatedComparer.cs
index c436fcb4a..1c5149517 100644
--- a/Emby.Server.Implementations/Sorting/DateCreatedComparer.cs
+++ b/Emby.Server.Implementations/Sorting/DateCreatedComparer.cs
@@ -18,6 +18,12 @@ namespace Emby.Server.Implementations.Sorting
/// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y)
{
+ if (x == null)
+ throw new ArgumentNullException(nameof(x));
+
+ if (y == null)
+ throw new ArgumentNullException(nameof(y));
+
return DateTime.Compare(x.DateCreated, y.DateCreated);
}
@@ -25,9 +31,6 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.DateCreated; }
- }
+ public string Name => ItemSortBy.DateCreated;
}
}
diff --git a/Emby.Server.Implementations/Sorting/DateLastMediaAddedComparer.cs b/Emby.Server.Implementations/Sorting/DateLastMediaAddedComparer.cs
index fc92505ac..ffe7fbaec 100644
--- a/Emby.Server.Implementations/Sorting/DateLastMediaAddedComparer.cs
+++ b/Emby.Server.Implementations/Sorting/DateLastMediaAddedComparer.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
@@ -42,7 +42,7 @@ namespace Emby.Server.Implementations.Sorting
/// </summary>
/// <param name="x">The x.</param>
/// <returns>DateTime.</returns>
- private DateTime GetDate(BaseItem x)
+ private static DateTime GetDate(BaseItem x)
{
var folder = x as Folder;
@@ -61,9 +61,6 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.DateLastContentAdded; }
- }
+ public string Name => ItemSortBy.DateLastContentAdded;
}
}
diff --git a/Emby.Server.Implementations/Sorting/DatePlayedComparer.cs b/Emby.Server.Implementations/Sorting/DatePlayedComparer.cs
index 388d2772e..c9ae68189 100644
--- a/Emby.Server.Implementations/Sorting/DatePlayedComparer.cs
+++ b/Emby.Server.Implementations/Sorting/DatePlayedComparer.cs
@@ -61,9 +61,6 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.DatePlayed; }
- }
+ public string Name => ItemSortBy.DatePlayed;
}
}
diff --git a/Emby.Server.Implementations/Sorting/GameSystemComparer.cs b/Emby.Server.Implementations/Sorting/GameSystemComparer.cs
index 4ee30397d..0b534b3cb 100644
--- a/Emby.Server.Implementations/Sorting/GameSystemComparer.cs
+++ b/Emby.Server.Implementations/Sorting/GameSystemComparer.cs
@@ -23,7 +23,7 @@ namespace Emby.Server.Implementations.Sorting
/// </summary>
/// <param name="x">The x.</param>
/// <returns>System.String.</returns>
- private string GetValue(BaseItem x)
+ private static string GetValue(BaseItem x)
{
var game = x as Game;
@@ -46,9 +46,6 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.GameSystem; }
- }
+ public string Name => ItemSortBy.GameSystem;
}
}
diff --git a/Emby.Server.Implementations/Sorting/IsFavoriteOrLikeComparer.cs b/Emby.Server.Implementations/Sorting/IsFavoriteOrLikeComparer.cs
index 27485f09e..48e3172ce 100644
--- a/Emby.Server.Implementations/Sorting/IsFavoriteOrLikeComparer.cs
+++ b/Emby.Server.Implementations/Sorting/IsFavoriteOrLikeComparer.cs
@@ -38,10 +38,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.IsFavoriteOrLiked; }
- }
+ public string Name => ItemSortBy.IsFavoriteOrLiked;
/// <summary>
/// Gets or sets the user data repository.
diff --git a/Emby.Server.Implementations/Sorting/IsFolderComparer.cs b/Emby.Server.Implementations/Sorting/IsFolderComparer.cs
index 756d13bd8..8b6cbb2db 100644
--- a/Emby.Server.Implementations/Sorting/IsFolderComparer.cs
+++ b/Emby.Server.Implementations/Sorting/IsFolderComparer.cs
@@ -22,7 +22,7 @@ namespace Emby.Server.Implementations.Sorting
/// </summary>
/// <param name="x">The x.</param>
/// <returns>System.String.</returns>
- private int GetValue(BaseItem x)
+ private static int GetValue(BaseItem x)
{
return x.IsFolder ? 0 : 1;
}
@@ -31,9 +31,6 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.IsFolder; }
- }
+ public string Name => ItemSortBy.IsFolder;
}
}
diff --git a/Emby.Server.Implementations/Sorting/IsPlayedComparer.cs b/Emby.Server.Implementations/Sorting/IsPlayedComparer.cs
index 987dc54a5..9f4fc2c06 100644
--- a/Emby.Server.Implementations/Sorting/IsPlayedComparer.cs
+++ b/Emby.Server.Implementations/Sorting/IsPlayedComparer.cs
@@ -38,10 +38,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.IsUnplayed; }
- }
+ public string Name => ItemSortBy.IsUnplayed;
/// <summary>
/// Gets or sets the user data repository.
diff --git a/Emby.Server.Implementations/Sorting/IsUnplayedComparer.cs b/Emby.Server.Implementations/Sorting/IsUnplayedComparer.cs
index 0f4e4c37e..d145aa8dd 100644
--- a/Emby.Server.Implementations/Sorting/IsUnplayedComparer.cs
+++ b/Emby.Server.Implementations/Sorting/IsUnplayedComparer.cs
@@ -38,10 +38,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.IsUnplayed; }
- }
+ public string Name => ItemSortBy.IsUnplayed;
/// <summary>
/// Gets or sets the user data repository.
diff --git a/Emby.Server.Implementations/Sorting/NameComparer.cs b/Emby.Server.Implementations/Sorting/NameComparer.cs
index 8ab5e5172..cfd810a6b 100644
--- a/Emby.Server.Implementations/Sorting/NameComparer.cs
+++ b/Emby.Server.Implementations/Sorting/NameComparer.cs
@@ -18,6 +18,12 @@ namespace Emby.Server.Implementations.Sorting
/// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y)
{
+ if (x == null)
+ throw new ArgumentNullException(nameof(x));
+
+ if (y == null)
+ throw new ArgumentNullException(nameof(y));
+
return string.Compare(x.Name, y.Name, StringComparison.CurrentCultureIgnoreCase);
}
@@ -25,9 +31,6 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.Name; }
- }
+ public string Name => ItemSortBy.Name;
}
}
diff --git a/Emby.Server.Implementations/Sorting/OfficialRatingComparer.cs b/Emby.Server.Implementations/Sorting/OfficialRatingComparer.cs
index 3eab4fccc..cd48e3048 100644
--- a/Emby.Server.Implementations/Sorting/OfficialRatingComparer.cs
+++ b/Emby.Server.Implementations/Sorting/OfficialRatingComparer.cs
@@ -2,6 +2,7 @@
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Querying;
+using System;
namespace Emby.Server.Implementations.Sorting
{
@@ -22,6 +23,12 @@ namespace Emby.Server.Implementations.Sorting
/// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y)
{
+ if (x == null)
+ throw new ArgumentNullException(nameof(x));
+
+ if (y == null)
+ throw new ArgumentNullException(nameof(y));
+
var levelX = string.IsNullOrEmpty(x.OfficialRating) ? 0 : _localization.GetRatingLevel(x.OfficialRating) ?? 0;
var levelY = string.IsNullOrEmpty(y.OfficialRating) ? 0 : _localization.GetRatingLevel(y.OfficialRating) ?? 0;
@@ -32,9 +39,6 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.OfficialRating; }
- }
+ public string Name => ItemSortBy.OfficialRating;
}
}
diff --git a/Emby.Server.Implementations/Sorting/PlayCountComparer.cs b/Emby.Server.Implementations/Sorting/PlayCountComparer.cs
index aecad7c58..9ed74f082 100644
--- a/Emby.Server.Implementations/Sorting/PlayCountComparer.cs
+++ b/Emby.Server.Implementations/Sorting/PlayCountComparer.cs
@@ -43,10 +43,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.PlayCount; }
- }
+ public string Name => ItemSortBy.PlayCount;
/// <summary>
/// Gets or sets the user data repository.
diff --git a/Emby.Server.Implementations/Sorting/PlayersComparer.cs b/Emby.Server.Implementations/Sorting/PlayersComparer.cs
index 3b54517c3..5b50ea48a 100644
--- a/Emby.Server.Implementations/Sorting/PlayersComparer.cs
+++ b/Emby.Server.Implementations/Sorting/PlayersComparer.cs
@@ -22,7 +22,7 @@ namespace Emby.Server.Implementations.Sorting
/// </summary>
/// <param name="x">The x.</param>
/// <returns>System.String.</returns>
- private int GetValue(BaseItem x)
+ private static int GetValue(BaseItem x)
{
var game = x as Game;
@@ -38,9 +38,6 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.Players; }
- }
+ public string Name => ItemSortBy.Players;
}
}
diff --git a/Emby.Server.Implementations/Sorting/PremiereDateComparer.cs b/Emby.Server.Implementations/Sorting/PremiereDateComparer.cs
index d7219c86f..cd712e3dc 100644
--- a/Emby.Server.Implementations/Sorting/PremiereDateComparer.cs
+++ b/Emby.Server.Implementations/Sorting/PremiereDateComparer.cs
@@ -26,7 +26,7 @@ namespace Emby.Server.Implementations.Sorting
/// </summary>
/// <param name="x">The x.</param>
/// <returns>DateTime.</returns>
- private DateTime GetDate(BaseItem x)
+ private static DateTime GetDate(BaseItem x)
{
if (x.PremiereDate.HasValue)
{
@@ -51,9 +51,6 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.PremiereDate; }
- }
+ public string Name => ItemSortBy.PremiereDate;
}
}
diff --git a/Emby.Server.Implementations/Sorting/ProductionYearComparer.cs b/Emby.Server.Implementations/Sorting/ProductionYearComparer.cs
index ea479419a..0aa5e833b 100644
--- a/Emby.Server.Implementations/Sorting/ProductionYearComparer.cs
+++ b/Emby.Server.Implementations/Sorting/ProductionYearComparer.cs
@@ -25,7 +25,7 @@ namespace Emby.Server.Implementations.Sorting
/// </summary>
/// <param name="x">The x.</param>
/// <returns>DateTime.</returns>
- private int GetValue(BaseItem x)
+ private static int GetValue(BaseItem x)
{
if (x.ProductionYear.HasValue)
{
@@ -44,9 +44,6 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.ProductionYear; }
- }
+ public string Name => ItemSortBy.ProductionYear;
}
}
diff --git a/Emby.Server.Implementations/Sorting/RandomComparer.cs b/Emby.Server.Implementations/Sorting/RandomComparer.cs
index 1fbecde56..c69ebe41a 100644
--- a/Emby.Server.Implementations/Sorting/RandomComparer.cs
+++ b/Emby.Server.Implementations/Sorting/RandomComparer.cs
@@ -25,9 +25,6 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.Random; }
- }
+ public string Name => ItemSortBy.Random;
}
}
diff --git a/Emby.Server.Implementations/Sorting/RuntimeComparer.cs b/Emby.Server.Implementations/Sorting/RuntimeComparer.cs
index 63c4758cb..77851d702 100644
--- a/Emby.Server.Implementations/Sorting/RuntimeComparer.cs
+++ b/Emby.Server.Implementations/Sorting/RuntimeComparer.cs
@@ -1,6 +1,7 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
+using System;
namespace Emby.Server.Implementations.Sorting
{
@@ -17,6 +18,12 @@ namespace Emby.Server.Implementations.Sorting
/// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y)
{
+ if (x == null)
+ throw new ArgumentNullException(nameof(x));
+
+ if (y == null)
+ throw new ArgumentNullException(nameof(y));
+
return (x.RunTimeTicks ?? 0).CompareTo(y.RunTimeTicks ?? 0);
}
@@ -24,9 +31,6 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.Runtime; }
- }
+ public string Name => ItemSortBy.Runtime;
}
}
diff --git a/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs b/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs
index b441a29c1..32a8f6b45 100644
--- a/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs
+++ b/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs
@@ -18,20 +18,17 @@ namespace Emby.Server.Implementations.Sorting
return string.Compare(GetValue(x), GetValue(y), StringComparison.CurrentCultureIgnoreCase);
}
- private string GetValue(BaseItem item)
+ private static string GetValue(BaseItem item)
{
var hasSeries = item as IHasSeries;
return hasSeries != null ? hasSeries.FindSeriesSortName() : null;
}
-
+
/// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.SeriesSortName; }
- }
+ public string Name => ItemSortBy.SeriesSortName;
}
}
diff --git a/Emby.Server.Implementations/Sorting/SortNameComparer.cs b/Emby.Server.Implementations/Sorting/SortNameComparer.cs
index f2a764840..6c42ed988 100644
--- a/Emby.Server.Implementations/Sorting/SortNameComparer.cs
+++ b/Emby.Server.Implementations/Sorting/SortNameComparer.cs
@@ -18,6 +18,12 @@ namespace Emby.Server.Implementations.Sorting
/// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y)
{
+ if (x == null)
+ throw new ArgumentNullException(nameof(x));
+
+ if (y == null)
+ throw new ArgumentNullException(nameof(y));
+
return string.Compare(x.SortName, y.SortName, StringComparison.CurrentCultureIgnoreCase);
}
@@ -25,9 +31,6 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.SortName; }
- }
+ public string Name => ItemSortBy.SortName;
}
}
diff --git a/Emby.Server.Implementations/Sorting/StartDateComparer.cs b/Emby.Server.Implementations/Sorting/StartDateComparer.cs
index 6be5f4883..7ae8037d9 100644
--- a/Emby.Server.Implementations/Sorting/StartDateComparer.cs
+++ b/Emby.Server.Implementations/Sorting/StartDateComparer.cs
@@ -24,7 +24,7 @@ namespace Emby.Server.Implementations.Sorting
/// </summary>
/// <param name="x">The x.</param>
/// <returns>DateTime.</returns>
- private DateTime GetDate(BaseItem x)
+ private static DateTime GetDate(BaseItem x)
{
var hasStartDate = x as LiveTvProgram;
@@ -39,9 +39,6 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.StartDate; }
- }
+ public string Name => ItemSortBy.StartDate;
}
}
diff --git a/Emby.Server.Implementations/Sorting/StudioComparer.cs b/Emby.Server.Implementations/Sorting/StudioComparer.cs
index 6735022af..605d65154 100644
--- a/Emby.Server.Implementations/Sorting/StudioComparer.cs
+++ b/Emby.Server.Implementations/Sorting/StudioComparer.cs
@@ -1,6 +1,7 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
+using System;
using System.Linq;
namespace Emby.Server.Implementations.Sorting
@@ -15,6 +16,11 @@ namespace Emby.Server.Implementations.Sorting
/// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y)
{
+ if (x == null)
+ throw new ArgumentNullException(nameof(x));
+
+ if (y == null)
+ throw new ArgumentNullException(nameof(y));
return AlphanumComparator.CompareValues(x.Studios.FirstOrDefault() ?? string.Empty, y.Studios.FirstOrDefault() ?? string.Empty);
}
@@ -22,9 +28,6 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
/// </summary>
/// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.Studio; }
- }
+ public string Name => ItemSortBy.Studio;
}
}
diff --git a/Emby.Server.Implementations/TV/TVSeriesManager.cs b/Emby.Server.Implementations/TV/TVSeriesManager.cs
index 1f9cb9164..652557466 100644
--- a/Emby.Server.Implementations/TV/TVSeriesManager.cs
+++ b/Emby.Server.Implementations/TV/TVSeriesManager.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.TV;
@@ -171,12 +171,12 @@ namespace Emby.Server.Implementations.TV
.Where(i => i != null);
}
- private string GetUniqueSeriesKey(Episode episode)
+ private static string GetUniqueSeriesKey(Episode episode)
{
return episode.SeriesPresentationUniqueKey;
}
- private string GetUniqueSeriesKey(Series series)
+ private static string GetUniqueSeriesKey(Series series)
{
return series.GetPresentationUniqueKey();
}
@@ -238,7 +238,7 @@ namespace Emby.Server.Implementations.TV
return new Tuple<DateTime, Func<Episode>>(DateTime.MinValue, getEpisode);
}
- private QueryResult<BaseItem> GetResult(IEnumerable<BaseItem> items, NextUpQuery query)
+ private static QueryResult<BaseItem> GetResult(IEnumerable<BaseItem> items, NextUpQuery query)
{
int totalCount = 0;
diff --git a/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/CharExtensions.cs b/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/CharExtensions.cs
index 59076bd66..cd77a30eb 100644
--- a/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/CharExtensions.cs
+++ b/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/CharExtensions.cs
@@ -333,7 +333,7 @@ namespace NLangDetect.Core.Extensions
if (!IsValidCodePoint(codePoint))
{
- throw new ArgumentException("Argument is not a valid code point.", "ch");
+ throw new ArgumentException("Argument is not a valid code point.", nameof(ch));
}
int top, bottom, current;
diff --git a/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/StringExtensions.cs b/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/StringExtensions.cs
index fc6c58a95..c60757c02 100644
--- a/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/StringExtensions.cs
+++ b/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/StringExtensions.cs
@@ -14,10 +14,10 @@ namespace NLangDetect.Core.Extensions
/// <exception cref="IndexOutOfRangeException"> if start or end are negative, if end is greater than length(), or if start is greater than end</exception>
public static string SubSequence(this string s, int start, int end)
{
- if (start < 0) throw new ArgumentOutOfRangeException("start", "Argument must not be negative.");
- if (end < 0) throw new ArgumentOutOfRangeException("end", "Argument must not be negative.");
- if (end > s.Length) throw new ArgumentOutOfRangeException("end", "Argument must not be greater than the input string's length.");
- if (start > end) throw new ArgumentOutOfRangeException("start", "Argument must not be greater than the 'end' argument.");
+ if (start < 0) throw new ArgumentOutOfRangeException(nameof(start), "Argument must not be negative.");
+ if (end < 0) throw new ArgumentOutOfRangeException(nameof(end), "Argument must not be negative.");
+ if (end > s.Length) throw new ArgumentOutOfRangeException(nameof(end), "Argument must not be greater than the input string's length.");
+ if (start > end) throw new ArgumentOutOfRangeException(nameof(start), "Argument must not be greater than the 'end' argument.");
return s.Substring(start, end - start);
}
diff --git a/Emby.Server.Implementations/TextEncoding/NLangDetect/LanguageDetector.cs b/Emby.Server.Implementations/TextEncoding/NLangDetect/LanguageDetector.cs
index fc7d420a9..044c7e759 100644
--- a/Emby.Server.Implementations/TextEncoding/NLangDetect/LanguageDetector.cs
+++ b/Emby.Server.Implementations/TextEncoding/NLangDetect/LanguageDetector.cs
@@ -23,7 +23,7 @@ namespace NLangDetect.Core
public static string DetectLanguage(string plainText)
{
- if (string.IsNullOrEmpty(plainText)) { throw new ArgumentException("Argument can't be null nor empty.", "plainText"); }
+ if (string.IsNullOrEmpty(plainText)) { throw new ArgumentException("Argument can't be null nor empty.", nameof(plainText)); }
Detector detector = DetectorFactory.Create(_DefaultAlpha);
diff --git a/Emby.Server.Implementations/TextEncoding/TextEncoding.cs b/Emby.Server.Implementations/TextEncoding/TextEncoding.cs
index f30c181a0..8f15d5a7b 100644
--- a/Emby.Server.Implementations/TextEncoding/TextEncoding.cs
+++ b/Emby.Server.Implementations/TextEncoding/TextEncoding.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Text;
using MediaBrowser.Model.IO;
using Microsoft.Extensions.Logging;
@@ -27,7 +27,7 @@ namespace Emby.Server.Implementations.TextEncoding
return Encoding.ASCII;
}
- private Encoding GetInitialEncoding(byte[] buffer, int count)
+ private static Encoding GetInitialEncoding(byte[] buffer, int count)
{
if (count >= 3)
{
@@ -137,6 +137,7 @@ namespace Emby.Server.Implementations.TextEncoding
}
catch (NLangDetectException ex)
{
+ _logger.LogDebug(ex, "LanguageDetector.DetectLanguage threw a NLangDetectException.");
}
try
@@ -145,6 +146,7 @@ namespace Emby.Server.Implementations.TextEncoding
}
catch (NLangDetectException ex)
{
+ _logger.LogDebug(ex, "LanguageDetector.DetectLanguage threw a NLangDetectException.");
}
try
@@ -153,6 +155,7 @@ namespace Emby.Server.Implementations.TextEncoding
}
catch (NLangDetectException ex)
{
+ _logger.LogDebug(ex, "LanguageDetector.DetectLanguage threw a NLangDetectException.");
}
return null;
@@ -162,7 +165,7 @@ namespace Emby.Server.Implementations.TextEncoding
{
if (string.IsNullOrWhiteSpace(charset))
{
- throw new ArgumentNullException("charset");
+ throw new ArgumentNullException(nameof(charset));
}
_logger.LogDebug("Getting encoding object for character set: {0}", charset);
@@ -187,7 +190,7 @@ namespace Emby.Server.Implementations.TextEncoding
return GetEncodingFromCharset(charset);
}
- private string GetFileCharacterSetFromLanguage(string language)
+ private static string GetFileCharacterSetFromLanguage(string language)
{
// https://developer.xamarin.com/api/type/System.Text.Encoding/
@@ -245,7 +248,7 @@ namespace Emby.Server.Implementations.TextEncoding
}
}
- private string DetectCharset(byte[] bytes, int index, int count, string language)
+ private static string DetectCharset(byte[] bytes, int index, int count, string language)
{
var detector = new CharsetDetector();
detector.Feed(bytes, index, count);
diff --git a/Emby.Server.Implementations/TextEncoding/TextEncodingDetect.cs b/Emby.Server.Implementations/TextEncoding/TextEncodingDetect.cs
index a0395a21b..7ac4a0b79 100644
--- a/Emby.Server.Implementations/TextEncoding/TextEncodingDetect.cs
+++ b/Emby.Server.Implementations/TextEncoding/TextEncodingDetect.cs
@@ -61,10 +61,7 @@
/// </summary>
public bool NullSuggestsBinary
{
- set
- {
- _nullSuggestsBinary = value;
- }
+ set => _nullSuggestsBinary = value;
}
public double Utf16ExpectedNullPercent
diff --git a/Emby.Server.Implementations/TextEncoding/UniversalDetector/CharsetDetector.cs b/Emby.Server.Implementations/TextEncoding/UniversalDetector/CharsetDetector.cs
index 942fda8d1..f2cecd03a 100644
--- a/Emby.Server.Implementations/TextEncoding/UniversalDetector/CharsetDetector.cs
+++ b/Emby.Server.Implementations/TextEncoding/UniversalDetector/CharsetDetector.cs
@@ -101,14 +101,10 @@ namespace UniversalDetector
base.Reset();
}
- public string Charset {
- get { return charset; }
- }
+ public string Charset => charset;
+
+ public float Confidence => confidence;
- public float Confidence {
- get { return confidence; }
- }
-
protected override void Report(string charset, float confidence)
{
this.charset = charset;
diff --git a/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/CodingStateMachine.cs b/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/CodingStateMachine.cs
index f837dd966..2a0e83b17 100644
--- a/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/CodingStateMachine.cs
+++ b/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/CodingStateMachine.cs
@@ -77,14 +77,8 @@ namespace UniversalDetector.Core
currentState = SMModel.START;
}
- public int CurrentCharLen
- {
- get { return currentCharLen; }
- }
+ public int CurrentCharLen => currentCharLen;
- public string ModelName
- {
- get { return model.Name; }
- }
+ public string ModelName => model.Name;
}
}
diff --git a/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/SMModel.cs b/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/SMModel.cs
index 2321ecad2..5b2f38303 100644
--- a/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/SMModel.cs
+++ b/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/SMModel.cs
@@ -55,18 +55,14 @@ namespace UniversalDetector.Core
private string name;
- public string Name {
- get { return name; }
- }
+ public string Name => name;
private int classFactor;
- public int ClassFactor {
- get { return classFactor; }
- }
+ public int ClassFactor => classFactor;
public SMModel(BitPackage classTable, int classFactor,
- BitPackage stateTable, int[] charLenTable, String name)
+ BitPackage stateTable, int[] charLenTable, string name)
{
this.classTable = classTable;
this.classFactor = classFactor;
diff --git a/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/SequenceModel.cs b/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/SequenceModel.cs
index 9048796b5..32b5df169 100644
--- a/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/SequenceModel.cs
+++ b/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/SequenceModel.cs
@@ -52,29 +52,23 @@ namespace UniversalDetector.Core
// freqSeqs / totalSeqs
protected float typicalPositiveRatio;
- public float TypicalPositiveRatio {
- get { return typicalPositiveRatio; }
- }
-
+ public float TypicalPositiveRatio => typicalPositiveRatio;
+
// not used
protected bool keepEnglishLetter;
- public bool KeepEnglishLetter {
- get { return keepEnglishLetter; }
- }
-
- protected String charsetName;
+ public bool KeepEnglishLetter => keepEnglishLetter;
+
+ protected string charsetName;
+
+ public string CharsetName => charsetName;
- public string CharsetName {
- get { return charsetName; }
- }
-
public SequenceModel(
byte[] charToOrderMap,
byte[] precedenceMatrix,
float typicalPositiveRatio,
bool keepEnglishLetter,
- String charsetName)
+ string charsetName)
{
this.charToOrderMap = charToOrderMap;
this.precedenceMatrix = precedenceMatrix;
diff --git a/Emby.Server.Implementations/Udp/UdpServer.cs b/Emby.Server.Implementations/Udp/UdpServer.cs
index 275bd83ea..91ef7b26f 100644
--- a/Emby.Server.Implementations/Udp/UdpServer.cs
+++ b/Emby.Server.Implementations/Udp/UdpServer.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Controller;
+using MediaBrowser.Controller;
using MediaBrowser.Model.ApiClient;
using Microsoft.Extensions.Logging;
using MediaBrowser.Model.Serialization;
@@ -169,6 +169,7 @@ namespace Emby.Server.Implementations.Udp
}
catch (ObjectDisposedException)
{
+ //TODO Investigate and properly fix.
}
catch (Exception ex)
{
@@ -191,6 +192,7 @@ namespace Emby.Server.Implementations.Udp
}
catch (ObjectDisposedException)
{
+ //TODO Investigate and properly fix.
}
catch (Exception ex)
{
@@ -263,12 +265,12 @@ namespace Emby.Server.Implementations.Udp
if (bytes == null)
{
- throw new ArgumentNullException("bytes");
+ throw new ArgumentNullException(nameof(bytes));
}
if (remoteEndPoint == null)
{
- throw new ArgumentNullException("remoteEndPoint");
+ throw new ArgumentNullException(nameof(remoteEndPoint));
}
try
diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs
index 82b61c15a..d76e7097f 100644
--- a/Emby.Server.Implementations/Updates/InstallationManager.cs
+++ b/Emby.Server.Implementations/Updates/InstallationManager.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
@@ -42,10 +42,7 @@ namespace Emby.Server.Implementations.Updates
/// </summary>
private ConcurrentBag<InstallationInfo> CompletedInstallationsInternal { get; set; }
- public IEnumerable<InstallationInfo> CompletedInstallations
- {
- get { return CompletedInstallationsInternal; }
- }
+ public IEnumerable<InstallationInfo> CompletedInstallations => CompletedInstallationsInternal;
#region PluginUninstalled Event
/// <summary>
@@ -129,7 +126,7 @@ namespace Emby.Server.Implementations.Updates
{
if (logger == null)
{
- throw new ArgumentNullException("logger");
+ throw new ArgumentNullException(nameof(logger));
}
CurrentInstallations = new List<Tuple<InstallationInfo, CancellationTokenSource>>();
@@ -147,7 +144,7 @@ namespace Emby.Server.Implementations.Updates
_logger = logger;
}
- private Version GetPackageVersion(PackageVersionInfo version)
+ private static Version GetPackageVersion(PackageVersionInfo version)
{
return new Version(ValueOrDefault(version.versionStr, "0.0.0.1"));
}
@@ -214,7 +211,7 @@ namespace Emby.Server.Implementations.Updates
{
Url = "https://www.mb3admin.local/admin/service/EmbyPackages.json",
CancellationToken = cancellationToken,
- Progress = new SimpleProgress<Double>(),
+ Progress = new SimpleProgress<double>(),
CacheLength = GetCacheLength(),
CacheMode = CacheMode.Unconditional
@@ -232,7 +229,7 @@ namespace Emby.Server.Implementations.Updates
return _applicationHost.SystemUpdateLevel;
}
- private TimeSpan GetCacheLength()
+ private static TimeSpan GetCacheLength()
{
return TimeSpan.FromMinutes(3);
}
@@ -313,7 +310,7 @@ namespace Emby.Server.Implementations.Updates
/// <param name="packageVersionInfo">The package version info.</param>
/// <param name="currentServerVersion">The current server version.</param>
/// <returns><c>true</c> if [is package version up to date] [the specified package version info]; otherwise, <c>false</c>.</returns>
- private bool IsPackageVersionUpToDate(PackageVersionInfo packageVersionInfo, Version currentServerVersion)
+ private static bool IsPackageVersionUpToDate(PackageVersionInfo packageVersionInfo, Version currentServerVersion)
{
if (string.IsNullOrEmpty(packageVersionInfo.requiredVersionStr))
{
@@ -423,12 +420,12 @@ namespace Emby.Server.Implementations.Updates
{
if (package == null)
{
- throw new ArgumentNullException("package");
+ throw new ArgumentNullException(nameof(package));
}
if (progress == null)
{
- throw new ArgumentNullException("progress");
+ throw new ArgumentNullException(nameof(progress));
}
var installationInfo = new InstallationInfo
@@ -587,7 +584,7 @@ namespace Emby.Server.Implementations.Updates
{
using (var stream = _fileSystem.OpenRead(tempFile))
{
- var check = Guid.Parse(BitConverter.ToString(_cryptographyProvider.ComputeMD5(stream)).Replace("-", String.Empty));
+ var check = Guid.Parse(BitConverter.ToString(_cryptographyProvider.ComputeMD5(stream)).Replace("-", string.Empty));
if (check != packageChecksum)
{
throw new Exception(string.Format("Download validation failed for {0}. Probably corrupted during transfer.", package.name));
diff --git a/Emby.Server.Implementations/UserViews/DynamicImageProvider.cs b/Emby.Server.Implementations/UserViews/DynamicImageProvider.cs
index c75033261..95b2e65be 100644
--- a/Emby.Server.Implementations/UserViews/DynamicImageProvider.cs
+++ b/Emby.Server.Implementations/UserViews/DynamicImageProvider.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
@@ -112,7 +112,7 @@ namespace Emby.Server.Implementations.UserViews
return false;
}
- private bool IsUsingCollectionStrip(UserView view)
+ private static bool IsUsingCollectionStrip(UserView view)
{
string[] collectionStripViewTypes =
{