aboutsummaryrefslogtreecommitdiff
path: root/Emby.Common.Implementations
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-11-11 15:37:53 -0500
committerGitHub <noreply@github.com>2016-11-11 15:37:53 -0500
commitb4c6cad2fa9256c4af83752a34679d2533c96b11 (patch)
tree43e25b4ed64a535823e21128ee74f3e0a1245069 /Emby.Common.Implementations
parent00316bc8ca9791f2ad68e84e29f2fbc6b1af2173 (diff)
parent2b19df9544315603673ff034e8fd621cf0b85a4b (diff)
Merge pull request #2281 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Common.Implementations')
-rw-r--r--Emby.Common.Implementations/Archiving/ZipClient.cs194
-rw-r--r--Emby.Common.Implementations/BaseApplicationHost.cs33
-rw-r--r--Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs29
-rw-r--r--Emby.Common.Implementations/IO/ManagedFileSystem.cs5
-rw-r--r--Emby.Common.Implementations/Net/NetSocket.cs6
-rw-r--r--Emby.Common.Implementations/Net/UdpSocket.cs2
-rw-r--r--Emby.Common.Implementations/Networking/NetworkManager.cs (renamed from Emby.Common.Implementations/Networking/BaseNetworkManager.cs)25
-rw-r--r--Emby.Common.Implementations/Serialization/JsonSerializer.cs227
-rw-r--r--Emby.Common.Implementations/project.json47
9 files changed, 524 insertions, 44 deletions
diff --git a/Emby.Common.Implementations/Archiving/ZipClient.cs b/Emby.Common.Implementations/Archiving/ZipClient.cs
new file mode 100644
index 000000000..791c6678c
--- /dev/null
+++ b/Emby.Common.Implementations/Archiving/ZipClient.cs
@@ -0,0 +1,194 @@
+using System.IO;
+using MediaBrowser.Model.IO;
+using SharpCompress.Archives.Rar;
+using SharpCompress.Archives.SevenZip;
+using SharpCompress.Archives.Tar;
+using SharpCompress.Common;
+using SharpCompress.Readers;
+using SharpCompress.Readers.Zip;
+
+namespace Emby.Common.Implementations.Archiving
+{
+ /// <summary>
+ /// Class DotNetZipClient
+ /// </summary>
+ public class ZipClient : IZipClient
+ {
+ private readonly IFileSystem _fileSystem;
+
+ public ZipClient(IFileSystem fileSystem)
+ {
+ _fileSystem = fileSystem;
+ }
+
+ /// <summary>
+ /// Extracts all.
+ /// </summary>
+ /// <param name="sourceFile">The source file.</param>
+ /// <param name="targetPath">The target path.</param>
+ /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
+ public void ExtractAll(string sourceFile, string targetPath, bool overwriteExistingFiles)
+ {
+ using (var fileStream = _fileSystem.OpenRead(sourceFile))
+ {
+ ExtractAll(fileStream, targetPath, overwriteExistingFiles);
+ }
+ }
+
+ /// <summary>
+ /// Extracts all.
+ /// </summary>
+ /// <param name="source">The source.</param>
+ /// <param name="targetPath">The target path.</param>
+ /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
+ public void ExtractAll(Stream source, string targetPath, bool overwriteExistingFiles)
+ {
+ using (var reader = ReaderFactory.Open(source))
+ {
+ var options = new ExtractionOptions();
+ options.ExtractFullPath = true;
+
+ if (overwriteExistingFiles)
+ {
+ options.Overwrite = true;
+ }
+
+ reader.WriteAllToDirectory(targetPath, options);
+ }
+ }
+
+ public void ExtractAllFromZip(Stream source, string targetPath, bool overwriteExistingFiles)
+ {
+ using (var reader = ZipReader.Open(source))
+ {
+ var options = new ExtractionOptions();
+ options.ExtractFullPath = true;
+
+ if (overwriteExistingFiles)
+ {
+ options.Overwrite = true;
+ }
+
+ reader.WriteAllToDirectory(targetPath, options);
+ }
+ }
+
+ /// <summary>
+ /// Extracts all from7z.
+ /// </summary>
+ /// <param name="sourceFile">The source file.</param>
+ /// <param name="targetPath">The target path.</param>
+ /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
+ public void ExtractAllFrom7z(string sourceFile, string targetPath, bool overwriteExistingFiles)
+ {
+ using (var fileStream = _fileSystem.OpenRead(sourceFile))
+ {
+ ExtractAllFrom7z(fileStream, targetPath, overwriteExistingFiles);
+ }
+ }
+
+ /// <summary>
+ /// Extracts all from7z.
+ /// </summary>
+ /// <param name="source">The source.</param>
+ /// <param name="targetPath">The target path.</param>
+ /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
+ public void ExtractAllFrom7z(Stream source, string targetPath, bool overwriteExistingFiles)
+ {
+ using (var archive = SevenZipArchive.Open(source))
+ {
+ using (var reader = archive.ExtractAllEntries())
+ {
+ var options = new ExtractionOptions();
+ options.ExtractFullPath = true;
+
+ if (overwriteExistingFiles)
+ {
+ options.Overwrite = true;
+ }
+
+ reader.WriteAllToDirectory(targetPath, options);
+ }
+ }
+ }
+
+
+ /// <summary>
+ /// Extracts all from tar.
+ /// </summary>
+ /// <param name="sourceFile">The source file.</param>
+ /// <param name="targetPath">The target path.</param>
+ /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
+ public void ExtractAllFromTar(string sourceFile, string targetPath, bool overwriteExistingFiles)
+ {
+ using (var fileStream = _fileSystem.OpenRead(sourceFile))
+ {
+ ExtractAllFromTar(fileStream, targetPath, overwriteExistingFiles);
+ }
+ }
+
+ /// <summary>
+ /// Extracts all from tar.
+ /// </summary>
+ /// <param name="source">The source.</param>
+ /// <param name="targetPath">The target path.</param>
+ /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
+ public void ExtractAllFromTar(Stream source, string targetPath, bool overwriteExistingFiles)
+ {
+ using (var archive = TarArchive.Open(source))
+ {
+ using (var reader = archive.ExtractAllEntries())
+ {
+ var options = new ExtractionOptions();
+ options.ExtractFullPath = true;
+
+ if (overwriteExistingFiles)
+ {
+ options.Overwrite = true;
+ }
+
+ reader.WriteAllToDirectory(targetPath, options);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Extracts all from rar.
+ /// </summary>
+ /// <param name="sourceFile">The source file.</param>
+ /// <param name="targetPath">The target path.</param>
+ /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
+ public void ExtractAllFromRar(string sourceFile, string targetPath, bool overwriteExistingFiles)
+ {
+ using (var fileStream = _fileSystem.OpenRead(sourceFile))
+ {
+ ExtractAllFromRar(fileStream, targetPath, overwriteExistingFiles);
+ }
+ }
+
+ /// <summary>
+ /// Extracts all from rar.
+ /// </summary>
+ /// <param name="source">The source.</param>
+ /// <param name="targetPath">The target path.</param>
+ /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
+ public void ExtractAllFromRar(Stream source, string targetPath, bool overwriteExistingFiles)
+ {
+ using (var archive = RarArchive.Open(source))
+ {
+ using (var reader = archive.ExtractAllEntries())
+ {
+ var options = new ExtractionOptions();
+ options.ExtractFullPath = true;
+
+ if (overwriteExistingFiles)
+ {
+ options.Overwrite = true;
+ }
+
+ reader.WriteAllToDirectory(targetPath, options);
+ }
+ }
+ }
+ }
+}
diff --git a/Emby.Common.Implementations/BaseApplicationHost.cs b/Emby.Common.Implementations/BaseApplicationHost.cs
index 0cf11e825..f0309511e 100644
--- a/Emby.Common.Implementations/BaseApplicationHost.cs
+++ b/Emby.Common.Implementations/BaseApplicationHost.cs
@@ -152,8 +152,6 @@ namespace Emby.Common.Implementations
protected IIsoManager IsoManager { get; private set; }
- protected ISystemEvents SystemEvents { get; private set; }
-
protected IProcessFactory ProcessFactory { get; private set; }
protected ITimerFactory TimerFactory { get; private set; }
protected ISocketFactory SocketFactory { get; private set; }
@@ -172,7 +170,7 @@ namespace Emby.Common.Implementations
protected ICryptoProvider CryptographyProvider = new CryptographyProvider();
- protected IEnvironmentInfo EnvironmentInfo = new Emby.Common.Implementations.EnvironmentInfo.EnvironmentInfo();
+ protected IEnvironmentInfo EnvironmentInfo { get; private set; }
private DeviceId _deviceId;
public string SystemId
@@ -193,20 +191,30 @@ namespace Emby.Common.Implementations
get { return EnvironmentInfo.OperatingSystemName; }
}
- public IMemoryStreamFactory MemoryStreamProvider { get; set; }
-
/// <summary>
/// The container
/// </summary>
protected readonly SimpleInjector.Container Container = new SimpleInjector.Container();
+ protected ISystemEvents SystemEvents { get; private set; }
+ protected IMemoryStreamFactory MemoryStreamFactory { get; private set; }
+
/// <summary>
/// Initializes a new instance of the <see cref="BaseApplicationHost{TApplicationPathsType}"/> class.
/// </summary>
protected BaseApplicationHost(TApplicationPathsType applicationPaths,
ILogManager logManager,
- IFileSystem fileSystem)
+ IFileSystem fileSystem,
+ IEnvironmentInfo environmentInfo,
+ ISystemEvents systemEvents,
+ IMemoryStreamFactory memoryStreamFactory,
+ INetworkManager networkManager)
{
+ NetworkManager = networkManager;
+ EnvironmentInfo = environmentInfo;
+ SystemEvents = systemEvents;
+ MemoryStreamFactory = memoryStreamFactory;
+
// hack alert, until common can target .net core
BaseExtensions.CryptographyProvider = CryptographyProvider;
@@ -233,9 +241,6 @@ namespace Emby.Common.Implementations
JsonSerializer = CreateJsonSerializer();
- MemoryStreamProvider = CreateMemoryStreamProvider();
- SystemEvents = CreateSystemEvents();
-
OnLoggerLoaded(true);
LogManager.LoggerLoaded += (s, e) => OnLoggerLoaded(false);
@@ -267,9 +272,6 @@ namespace Emby.Common.Implementations
progress.Report(100);
}
- protected abstract IMemoryStreamFactory CreateMemoryStreamProvider();
- protected abstract ISystemEvents CreateSystemEvents();
-
protected virtual void OnLoggerLoaded(bool isFirstLoad)
{
Logger.Info("Application version: {0}", ApplicationVersion);
@@ -521,7 +523,7 @@ return null;
RegisterSingleInstance(JsonSerializer);
RegisterSingleInstance(XmlSerializer);
- RegisterSingleInstance(MemoryStreamProvider);
+ RegisterSingleInstance(MemoryStreamFactory);
RegisterSingleInstance(SystemEvents);
RegisterSingleInstance(LogManager);
@@ -532,10 +534,9 @@ return null;
RegisterSingleInstance(FileSystemManager);
- HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, LogManager.GetLogger("HttpClient"), FileSystemManager, MemoryStreamProvider);
+ HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, LogManager.GetLogger("HttpClient"), FileSystemManager, MemoryStreamFactory);
RegisterSingleInstance(HttpClient);
- NetworkManager = CreateNetworkManager(LogManager.GetLogger("NetworkManager"));
RegisterSingleInstance(NetworkManager);
IsoManager = new IsoManager();
@@ -588,8 +589,6 @@ return null;
}
}
- protected abstract INetworkManager CreateNetworkManager(ILogger logger);
-
/// <summary>
/// Creates an instance of type and resolves all constructor dependancies
/// </summary>
diff --git a/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs b/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs
index 8cea617ea..6a1b3ef74 100644
--- a/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs
+++ b/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs
@@ -9,6 +9,8 @@ namespace Emby.Common.Implementations.EnvironmentInfo
{
public class EnvironmentInfo : IEnvironmentInfo
{
+ public MediaBrowser.Model.System.Architecture? CustomArchitecture { get; set; }
+
public MediaBrowser.Model.System.OperatingSystem OperatingSystem
{
get
@@ -66,5 +68,32 @@ namespace Emby.Common.Implementations.EnvironmentInfo
return "1.0";
}
}
+
+ public MediaBrowser.Model.System.Architecture SystemArchitecture
+ {
+ get
+ {
+ if (CustomArchitecture.HasValue)
+ {
+ return CustomArchitecture.Value;
+ }
+#if NET46
+ return Environment.Is64BitOperatingSystem ? MediaBrowser.Model.System.Architecture.X64 : MediaBrowser.Model.System.Architecture.X86;
+#elif NETSTANDARD1_6
+ switch(System.Runtime.InteropServices.RuntimeInformation.OSArchitecture)
+ {
+ case System.Runtime.InteropServices.Architecture.Arm:
+ return MediaBrowser.Model.System.Architecture.Arm;
+ case System.Runtime.InteropServices.Architecture.Arm64:
+ return MediaBrowser.Model.System.Architecture.Arm64;
+ case System.Runtime.InteropServices.Architecture.X64:
+ return MediaBrowser.Model.System.Architecture.X64;
+ case System.Runtime.InteropServices.Architecture.X86:
+ return MediaBrowser.Model.System.Architecture.X86;
+ }
+#endif
+ return MediaBrowser.Model.System.Architecture.X64;
+ }
+ }
}
}
diff --git a/Emby.Common.Implementations/IO/ManagedFileSystem.cs b/Emby.Common.Implementations/IO/ManagedFileSystem.cs
index 37b457598..81ca8dcff 100644
--- a/Emby.Common.Implementations/IO/ManagedFileSystem.cs
+++ b/Emby.Common.Implementations/IO/ManagedFileSystem.cs
@@ -761,5 +761,10 @@ namespace Emby.Common.Implementations.IO
var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
return Directory.EnumerateFileSystemEntries(path, "*", searchOption);
}
+
+ public virtual void SetExecutable(string path)
+ {
+
+ }
}
}
diff --git a/Emby.Common.Implementations/Net/NetSocket.cs b/Emby.Common.Implementations/Net/NetSocket.cs
index 72faa41a9..faa1a81e2 100644
--- a/Emby.Common.Implementations/Net/NetSocket.cs
+++ b/Emby.Common.Implementations/Net/NetSocket.cs
@@ -23,7 +23,7 @@ namespace Emby.Common.Implementations.Net
{
get
{
- return BaseNetworkManager.ToIpEndPointInfo((IPEndPoint)Socket.LocalEndPoint);
+ return NetworkManager.ToIpEndPointInfo((IPEndPoint)Socket.LocalEndPoint);
}
}
@@ -31,7 +31,7 @@ namespace Emby.Common.Implementations.Net
{
get
{
- return BaseNetworkManager.ToIpEndPointInfo((IPEndPoint)Socket.RemoteEndPoint);
+ return NetworkManager.ToIpEndPointInfo((IPEndPoint)Socket.RemoteEndPoint);
}
}
@@ -64,7 +64,7 @@ namespace Emby.Common.Implementations.Net
public void Bind(IpEndPointInfo endpoint)
{
- var nativeEndpoint = BaseNetworkManager.ToIPEndPoint(endpoint);
+ var nativeEndpoint = NetworkManager.ToIPEndPoint(endpoint);
Socket.Bind(nativeEndpoint);
}
diff --git a/Emby.Common.Implementations/Net/UdpSocket.cs b/Emby.Common.Implementations/Net/UdpSocket.cs
index 244b37bb4..eca82034b 100644
--- a/Emby.Common.Implementations/Net/UdpSocket.cs
+++ b/Emby.Common.Implementations/Net/UdpSocket.cs
@@ -175,7 +175,7 @@ namespace Emby.Common.Implementations.Net
return null;
}
- return BaseNetworkManager.ToIpEndPointInfo(endpoint);
+ return NetworkManager.ToIpEndPointInfo(endpoint);
}
private void ProcessResponse(IAsyncResult asyncResult)
diff --git a/Emby.Common.Implementations/Networking/BaseNetworkManager.cs b/Emby.Common.Implementations/Networking/NetworkManager.cs
index f1ac8413b..e33697337 100644
--- a/Emby.Common.Implementations/Networking/BaseNetworkManager.cs
+++ b/Emby.Common.Implementations/Networking/NetworkManager.cs
@@ -9,15 +9,17 @@ using System.Net.Sockets;
using System.Threading.Tasks;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.Net;
+using MediaBrowser.Model.IO;
+using MediaBrowser.Common.Net;
namespace Emby.Common.Implementations.Networking
{
- public abstract class BaseNetworkManager
+ public class NetworkManager : INetworkManager
{
protected ILogger Logger { get; private set; }
private DateTime _lastRefresh;
- protected BaseNetworkManager(ILogger logger)
+ public NetworkManager(ILogger logger)
{
Logger = logger;
}
@@ -481,5 +483,24 @@ namespace Emby.Common.Implementations.Networking
var addresses = await Dns.GetHostAddressesAsync(host).ConfigureAwait(false);
return addresses.Select(ToIpAddressInfo).ToArray();
}
+
+ /// <summary>
+ /// Gets the network shares.
+ /// </summary>
+ /// <param name="path">The path.</param>
+ /// <returns>IEnumerable{NetworkShare}.</returns>
+ public IEnumerable<NetworkShare> GetNetworkShares(string path)
+ {
+ return new List<NetworkShare>();
+ }
+
+ /// <summary>
+ /// Gets available devices within the domain
+ /// </summary>
+ /// <returns>PC's in the Domain</returns>
+ public IEnumerable<FileSystemEntryInfo> GetNetworkDevices()
+ {
+ return new List<FileSystemEntryInfo>();
+ }
}
}
diff --git a/Emby.Common.Implementations/Serialization/JsonSerializer.cs b/Emby.Common.Implementations/Serialization/JsonSerializer.cs
new file mode 100644
index 000000000..c9db33689
--- /dev/null
+++ b/Emby.Common.Implementations/Serialization/JsonSerializer.cs
@@ -0,0 +1,227 @@
+using System;
+using System.IO;
+using MediaBrowser.Model.IO;
+using MediaBrowser.Model.Logging;
+using MediaBrowser.Model.Serialization;
+
+namespace Emby.Common.Implementations.Serialization
+{
+ /// <summary>
+ /// Provides a wrapper around third party json serialization.
+ /// </summary>
+ public class JsonSerializer : IJsonSerializer
+ {
+ private readonly IFileSystem _fileSystem;
+ private readonly ILogger _logger;
+
+ public JsonSerializer(IFileSystem fileSystem, ILogger logger)
+ {
+ _fileSystem = fileSystem;
+ _logger = logger;
+ Configure();
+ }
+
+ /// <summary>
+ /// Serializes to stream.
+ /// </summary>
+ /// <param name="obj">The obj.</param>
+ /// <param name="stream">The stream.</param>
+ /// <exception cref="System.ArgumentNullException">obj</exception>
+ public void SerializeToStream(object obj, Stream stream)
+ {
+ if (obj == null)
+ {
+ throw new ArgumentNullException("obj");
+ }
+
+ if (stream == null)
+ {
+ throw new ArgumentNullException("stream");
+ }
+
+ ServiceStack.Text.JsonSerializer.SerializeToStream(obj, obj.GetType(), stream);
+ }
+
+ /// <summary>
+ /// Serializes to file.
+ /// </summary>
+ /// <param name="obj">The obj.</param>
+ /// <param name="file">The file.</param>
+ /// <exception cref="System.ArgumentNullException">obj</exception>
+ public void SerializeToFile(object obj, string file)
+ {
+ if (obj == null)
+ {
+ throw new ArgumentNullException("obj");
+ }
+
+ if (string.IsNullOrEmpty(file))
+ {
+ throw new ArgumentNullException("file");
+ }
+
+ using (Stream stream = _fileSystem.GetFileStream(file, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
+ {
+ SerializeToStream(obj, stream);
+ }
+ }
+
+ private Stream OpenFile(string path)
+ {
+ _logger.Debug("Deserializing file {0}", path);
+ return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 131072);
+ }
+
+ /// <summary>
+ /// Deserializes from file.
+ /// </summary>
+ /// <param name="type">The type.</param>
+ /// <param name="file">The file.</param>
+ /// <returns>System.Object.</returns>
+ /// <exception cref="System.ArgumentNullException">type</exception>
+ public object DeserializeFromFile(Type type, string file)
+ {
+ if (type == null)
+ {
+ throw new ArgumentNullException("type");
+ }
+
+ if (string.IsNullOrEmpty(file))
+ {
+ throw new ArgumentNullException("file");
+ }
+
+ using (Stream stream = OpenFile(file))
+ {
+ return DeserializeFromStream(stream, type);
+ }
+ }
+
+ /// <summary>
+ /// Deserializes from file.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="file">The file.</param>
+ /// <returns>``0.</returns>
+ /// <exception cref="System.ArgumentNullException">file</exception>
+ public T DeserializeFromFile<T>(string file)
+ where T : class
+ {
+ if (string.IsNullOrEmpty(file))
+ {
+ throw new ArgumentNullException("file");
+ }
+
+ using (Stream stream = OpenFile(file))
+ {
+ return DeserializeFromStream<T>(stream);
+ }
+ }
+
+ /// <summary>
+ /// Deserializes from stream.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="stream">The stream.</param>
+ /// <returns>``0.</returns>
+ /// <exception cref="System.ArgumentNullException">stream</exception>
+ public T DeserializeFromStream<T>(Stream stream)
+ {
+ if (stream == null)
+ {
+ throw new ArgumentNullException("stream");
+ }
+
+ return ServiceStack.Text.JsonSerializer.DeserializeFromStream<T>(stream);
+ }
+
+ /// <summary>
+ /// Deserializes from string.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="text">The text.</param>
+ /// <returns>``0.</returns>
+ /// <exception cref="System.ArgumentNullException">text</exception>
+ public T DeserializeFromString<T>(string text)
+ {
+ if (string.IsNullOrEmpty(text))
+ {
+ throw new ArgumentNullException("text");
+ }
+
+ return ServiceStack.Text.JsonSerializer.DeserializeFromString<T>(text);
+ }
+
+ /// <summary>
+ /// Deserializes from stream.
+ /// </summary>
+ /// <param name="stream">The stream.</param>
+ /// <param name="type">The type.</param>
+ /// <returns>System.Object.</returns>
+ /// <exception cref="System.ArgumentNullException">stream</exception>
+ public object DeserializeFromStream(Stream stream, Type type)
+ {
+ if (stream == null)
+ {
+ throw new ArgumentNullException("stream");
+ }
+
+ if (type == null)
+ {
+ throw new ArgumentNullException("type");
+ }
+
+ return ServiceStack.Text.JsonSerializer.DeserializeFromStream(type, stream);
+ }
+
+ /// <summary>
+ /// Configures this instance.
+ /// </summary>
+ private void Configure()
+ {
+ ServiceStack.Text.JsConfig.DateHandler = ServiceStack.Text.DateHandler.ISO8601;
+ ServiceStack.Text.JsConfig.ExcludeTypeInfo = true;
+ ServiceStack.Text.JsConfig.IncludeNullValues = false;
+ ServiceStack.Text.JsConfig.AlwaysUseUtc = true;
+ ServiceStack.Text.JsConfig.AssumeUtc = true;
+ }
+
+ /// <summary>
+ /// Deserializes from string.
+ /// </summary>
+ /// <param name="json">The json.</param>
+ /// <param name="type">The type.</param>
+ /// <returns>System.Object.</returns>
+ /// <exception cref="System.ArgumentNullException">json</exception>
+ public object DeserializeFromString(string json, Type type)
+ {
+ if (string.IsNullOrEmpty(json))
+ {
+ throw new ArgumentNullException("json");
+ }
+
+ if (type == null)
+ {
+ throw new ArgumentNullException("type");
+ }
+
+ return ServiceStack.Text.JsonSerializer.DeserializeFromString(json, type);
+ }
+
+ /// <summary>
+ /// Serializes to string.
+ /// </summary>
+ /// <param name="obj">The obj.</param>
+ /// <returns>System.String.</returns>
+ /// <exception cref="System.ArgumentNullException">obj</exception>
+ public string SerializeToString(object obj)
+ {
+ if (obj == null)
+ {
+ throw new ArgumentNullException("obj");
+ }
+
+ return ServiceStack.Text.JsonSerializer.SerializeToString(obj, obj.GetType());
+ }
+ }
+}
diff --git a/Emby.Common.Implementations/project.json b/Emby.Common.Implementations/project.json
index 2b2357e38..b0a35bdf3 100644
--- a/Emby.Common.Implementations/project.json
+++ b/Emby.Common.Implementations/project.json
@@ -2,7 +2,7 @@
"version": "1.0.0-*",
"dependencies": {
-
+
},
"frameworks": {
@@ -19,46 +19,51 @@
"System.Text.Encoding": "4.0.0.0",
"System.Threading": "4.0.0.0",
"System.Threading.Tasks": "4.0.0.0",
- "System.Xml.ReaderWriter": "4.0.0"
+ "System.Xml.ReaderWriter": "4.0.0"
},
"dependencies": {
"SimpleInjector": "3.2.4",
+ "ServiceStack.Text": "4.5.4",
"NLog": "4.4.0-betaV15",
+ "sharpcompress": "0.14.0",
"MediaBrowser.Model": {
"target": "project"
},
"MediaBrowser.Common": {
"target": "project"
- }
- }
+ }
+ }
},
"netstandard1.6": {
"imports": "dnxcore50",
"dependencies": {
"NETStandard.Library": "1.6.0",
- "System.IO.FileSystem.DriveInfo": "4.0.0",
- "System.Diagnostics.Process": "4.1.0",
- "System.Threading.Timer": "4.0.1",
- "System.Net.Requests": "4.0.11",
- "System.Xml.ReaderWriter": "4.0.11",
- "System.Xml.XmlSerializer": "4.0.11",
- "System.Net.Http": "4.1.0",
- "System.Net.Primitives": "4.0.11",
- "System.Net.Sockets": "4.1.0",
- "System.Net.NetworkInformation": "4.1.0",
- "System.Net.NameResolution": "4.0.0",
- "System.Runtime.InteropServices.RuntimeInformation": "4.0.0",
- "System.Reflection": "4.1.0",
- "System.Reflection.Primitives": "4.0.1",
- "System.Runtime.Loader": "4.0.0",
- "SimpleInjector": "3.2.4",
+ "System.IO.FileSystem.DriveInfo": "4.0.0",
+ "System.Diagnostics.Process": "4.1.0",
+ "System.Threading.Timer": "4.0.1",
+ "System.Net.Requests": "4.0.11",
+ "System.Xml.ReaderWriter": "4.0.11",
+ "System.Xml.XmlSerializer": "4.0.11",
+ "System.Net.Http": "4.1.0",
+ "System.Net.Primitives": "4.0.11",
+ "System.Net.Sockets": "4.1.0",
+ "System.Net.NetworkInformation": "4.1.0",
+ "System.Net.NameResolution": "4.0.0",
+ "System.Runtime.InteropServices.RuntimeInformation": "4.0.0",
+ "System.Reflection": "4.1.0",
+ "System.Reflection.Primitives": "4.0.1",
+ "System.Runtime.Loader": "4.0.0",
+ "SimpleInjector": "3.2.4",
+ "ServiceStack.Text.Core": "1.0.27",
"NLog": "4.4.0-betaV15",
+ "sharpcompress": "0.14.0",
"MediaBrowser.Model": {
"target": "project"
},
"MediaBrowser.Common": {
"target": "project"
- } }
+ }
+ }
}
}
}