aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Devices/DeviceId.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Devices/DeviceId.cs')
-rw-r--r--Emby.Server.Implementations/Devices/DeviceId.cs41
1 files changed, 19 insertions, 22 deletions
diff --git a/Emby.Server.Implementations/Devices/DeviceId.cs b/Emby.Server.Implementations/Devices/DeviceId.cs
index 90cef5d06..00761809a 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;
@@ -10,15 +10,12 @@ namespace Emby.Server.Implementations.Devices
public class DeviceId
{
private readonly IApplicationPaths _appPaths;
- private readonly ILogger _logger;
- private readonly IFileSystem _fileSystem;
+ private readonly ILogger _logger;
+ private readonly IFileSystem _fileSystem;
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()
{
@@ -26,10 +23,9 @@ namespace Emby.Server.Implementations.Devices
{
lock (_syncLock)
{
- var value = File.ReadAllText(CachePath, Encoding.UTF8);
+ var value = File.ReadAllText(CachePath, Encoding.UTF8);
- Guid guid;
- if (Guid.TryParse(value, out guid))
+ if (Guid.TryParse(value, out var guid))
{
return value;
}
@@ -57,7 +53,7 @@ namespace Emby.Server.Implementations.Devices
{
var path = CachePath;
- _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
+ _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
lock (_syncLock)
{
@@ -70,7 +66,7 @@ namespace Emby.Server.Implementations.Devices
}
}
- private string GetNewId()
+ private static string GetNewId()
{
return Guid.NewGuid().ToString("N");
}
@@ -90,20 +86,21 @@ namespace Emby.Server.Implementations.Devices
private string _id;
- public DeviceId(IApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem)
+ public DeviceId(
+ IApplicationPaths appPaths,
+ ILoggerFactory loggerFactory,
+ IFileSystem fileSystem)
{
- if (fileSystem == null) {
- throw new ArgumentNullException ("fileSystem");
- }
+ if (fileSystem == null)
+ {
+ throw new ArgumentNullException(nameof(fileSystem));
+ }
_appPaths = appPaths;
- _logger = logger;
- _fileSystem = fileSystem;
+ _logger = loggerFactory.CreateLogger("SystemId");
+ _fileSystem = fileSystem;
}
- public string Value
- {
- get { return _id ?? (_id = GetDeviceId()); }
- }
+ public string Value => _id ?? (_id = GetDeviceId());
}
}