aboutsummaryrefslogtreecommitdiff
path: root/Emby.Common.Implementations
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-11-05 15:36:32 -0400
committerGitHub <noreply@github.com>2016-11-05 15:36:32 -0400
commit36c01cfc7649b95c7ff63833424f1952e7889d07 (patch)
treebe560399d41766ff4ef6e49dd90c488e88838488 /Emby.Common.Implementations
parent398398f3018434de7c057dffccb6c0373ff97526 (diff)
parenta4832369bf3abe7afbc2a35faa991be1ace64494 (diff)
Merge pull request #2274 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Common.Implementations')
-rw-r--r--Emby.Common.Implementations/BaseApplicationHost.cs17
-rw-r--r--Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs70
-rw-r--r--Emby.Common.Implementations/Net/SocketFactory.cs33
-rw-r--r--Emby.Common.Implementations/Net/UdpSocket.cs75
-rw-r--r--Emby.Common.Implementations/Networking/BaseNetworkManager.cs116
-rw-r--r--Emby.Common.Implementations/Serialization/XmlSerializer.cs17
-rw-r--r--Emby.Common.Implementations/project.json9
7 files changed, 221 insertions, 116 deletions
diff --git a/Emby.Common.Implementations/BaseApplicationHost.cs b/Emby.Common.Implementations/BaseApplicationHost.cs
index bdebe894e..9585abb2a 100644
--- a/Emby.Common.Implementations/BaseApplicationHost.cs
+++ b/Emby.Common.Implementations/BaseApplicationHost.cs
@@ -29,6 +29,7 @@ using MediaBrowser.Common.Extensions;
using Emby.Common.Implementations.Cryptography;
using Emby.Common.Implementations.Diagnostics;
using Emby.Common.Implementations.Net;
+using Emby.Common.Implementations.EnvironmentInfo;
using Emby.Common.Implementations.Threading;
using MediaBrowser.Common;
using MediaBrowser.Common.IO;
@@ -171,6 +172,8 @@ namespace Emby.Common.Implementations
protected ICryptographyProvider CryptographyProvider = new CryptographyProvider();
+ protected IEnvironmentInfo EnvironmentInfo = new Emby.Common.Implementations.EnvironmentInfo.EnvironmentInfo();
+
private DeviceId _deviceId;
public string SystemId
{
@@ -187,16 +190,7 @@ namespace Emby.Common.Implementations
public virtual string OperatingSystemDisplayName
{
- get
- {
-#if NET46
- return Environment.OSVersion.VersionString;
-#endif
-#if NETSTANDARD1_6
- return System.Runtime.InteropServices.RuntimeInformation.OSDescription;
-#endif
- return "Operating System";
- }
+ get { return EnvironmentInfo.OperatingSystemName; }
}
public IMemoryStreamProvider MemoryStreamProvider { get; set; }
@@ -216,7 +210,7 @@ namespace Emby.Common.Implementations
// hack alert, until common can target .net core
BaseExtensions.CryptographyProvider = CryptographyProvider;
- XmlSerializer = new XmlSerializer(fileSystem, logManager.GetLogger("XmlSerializer"));
+ XmlSerializer = new MyXmlSerializer(fileSystem, logManager.GetLogger("XmlSerializer"));
FailedAssemblies = new List<string>();
ApplicationPaths = applicationPaths;
@@ -534,6 +528,7 @@ return null;
RegisterSingleInstance(Logger);
RegisterSingleInstance(TaskManager);
+ RegisterSingleInstance(EnvironmentInfo);
RegisterSingleInstance(FileSystemManager);
diff --git a/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs b/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs
new file mode 100644
index 000000000..8cea617ea
--- /dev/null
+++ b/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+using MediaBrowser.Model.System;
+
+namespace Emby.Common.Implementations.EnvironmentInfo
+{
+ public class EnvironmentInfo : IEnvironmentInfo
+ {
+ public MediaBrowser.Model.System.OperatingSystem OperatingSystem
+ {
+ get
+ {
+#if NET46
+ switch (Environment.OSVersion.Platform)
+ {
+ case PlatformID.MacOSX:
+ return MediaBrowser.Model.System.OperatingSystem.OSX;
+ case PlatformID.Win32NT:
+ return MediaBrowser.Model.System.OperatingSystem.Windows;
+ case PlatformID.Unix:
+ return MediaBrowser.Model.System.OperatingSystem.Linux;
+ }
+#elif NETSTANDARD1_6
+ if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ {
+ return OperatingSystem.OSX;
+ }
+ if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ {
+ return OperatingSystem.Windows;
+ }
+ if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ {
+ return OperatingSystem.Linux;
+ }
+#endif
+ return MediaBrowser.Model.System.OperatingSystem.Windows;
+ }
+ }
+
+ public string OperatingSystemName
+ {
+ get
+ {
+#if NET46
+ return Environment.OSVersion.Platform.ToString();
+#elif NETSTANDARD1_6
+ return System.Runtime.InteropServices.RuntimeInformation.OSDescription;
+#endif
+ return "Operating System";
+ }
+ }
+
+ public string OperatingSystemVersion
+ {
+ get
+ {
+#if NET46
+ return Environment.OSVersion.Version.ToString() + " " + Environment.OSVersion.ServicePack.ToString();
+#elif NETSTANDARD1_6
+ return System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription;
+#endif
+ return "1.0";
+ }
+ }
+ }
+}
diff --git a/Emby.Common.Implementations/Net/SocketFactory.cs b/Emby.Common.Implementations/Net/SocketFactory.cs
index 3a2cea12a..bb38c72da 100644
--- a/Emby.Common.Implementations/Net/SocketFactory.cs
+++ b/Emby.Common.Implementations/Net/SocketFactory.cs
@@ -37,22 +37,44 @@ namespace Emby.Common.Implementations.Net
#region ISocketFactory Members
/// <summary>
+ /// Creates a new UDP socket and binds it to the specified local port.
+ /// </summary>
+ /// <param name="localPort">An integer specifying the local port to bind the socket to.</param>
+ public IUdpSocket CreateUdpSocket(int localPort)
+ {
+ if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", "localPort");
+
+ var retVal = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
+ try
+ {
+ retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
+ return new UdpSocket(retVal, localPort, _LocalIP);
+ }
+ catch
+ {
+ if (retVal != null)
+ retVal.Dispose();
+
+ throw;
+ }
+ }
+
+ /// <summary>
/// Creates a new UDP socket that is a member of the SSDP multicast local admin group and binds it to the specified local port.
/// </summary>
/// <param name="localPort">An integer specifying the local port to bind the socket to.</param>
/// <returns>An implementation of the <see cref="IUdpSocket"/> interface used by RSSDP components to perform socket operations.</returns>
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "The purpose of this method is to create and returns a disposable result, it is up to the caller to dispose it when they are done with it.")]
- public IUdpSocket CreateUdpSocket(int localPort)
+ public IUdpSocket CreateSsdpUdpSocket(int localPort)
{
if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", "localPort");
- var retVal = new Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Dgram, System.Net.Sockets.ProtocolType.Udp);
+ var retVal = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
try
{
retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 4);
retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse("239.255.255.250"), _LocalIP));
- return new UdpSocket(retVal, localPort, _LocalIP.ToString());
+ return new UdpSocket(retVal, localPort, _LocalIP);
}
catch
{
@@ -70,7 +92,6 @@ namespace Emby.Common.Implementations.Net
/// <param name="multicastTimeToLive">The multicast time to live value for the socket.</param>
/// <param name="localPort">The number of the local port to bind to.</param>
/// <returns></returns>
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "ip"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "The purpose of this method is to create and returns a disposable result, it is up to the caller to dispose it when they are done with it.")]
public IUdpSocket CreateUdpMulticastSocket(string ipAddress, int multicastTimeToLive, int localPort)
{
if (ipAddress == null) throw new ArgumentNullException("ipAddress");
@@ -97,7 +118,7 @@ namespace Emby.Common.Implementations.Net
retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse(ipAddress), _LocalIP));
retVal.MulticastLoopback = true;
- return new UdpSocket(retVal, localPort, _LocalIP.ToString());
+ return new UdpSocket(retVal, localPort, _LocalIP);
}
catch
{
diff --git a/Emby.Common.Implementations/Net/UdpSocket.cs b/Emby.Common.Implementations/Net/UdpSocket.cs
index 86ce9c83b..d999d3fe8 100644
--- a/Emby.Common.Implementations/Net/UdpSocket.cs
+++ b/Emby.Common.Implementations/Net/UdpSocket.cs
@@ -17,26 +17,20 @@ namespace Emby.Common.Implementations.Net
#region Fields
- private System.Net.Sockets.Socket _Socket;
+ private Socket _Socket;
private int _LocalPort;
#endregion
#region Constructors
- public UdpSocket(System.Net.Sockets.Socket socket, int localPort, string ipAddress)
+ public UdpSocket(Socket socket, int localPort, IPAddress ip)
{
if (socket == null) throw new ArgumentNullException("socket");
_Socket = socket;
_LocalPort = localPort;
- IPAddress ip = null;
- if (String.IsNullOrEmpty(ipAddress))
- ip = IPAddress.Any;
- else
- ip = IPAddress.Parse(ipAddress);
-
_Socket.Bind(new IPEndPoint(ip, _LocalPort));
if (_LocalPort == 0)
_LocalPort = (_Socket.LocalEndPoint as IPEndPoint).Port;
@@ -46,18 +40,18 @@ namespace Emby.Common.Implementations.Net
#region IUdpSocket Members
- public Task<ReceivedUdpData> ReceiveAsync()
+ public Task<SocketReceiveResult> ReceiveAsync()
{
ThrowIfDisposed();
- var tcs = new TaskCompletionSource<ReceivedUdpData>();
+ var tcs = new TaskCompletionSource<SocketReceiveResult>();
- System.Net.EndPoint receivedFromEndPoint = new IPEndPoint(IPAddress.Any, 0);
+ EndPoint receivedFromEndPoint = new IPEndPoint(IPAddress.Any, 0);
var state = new AsyncReceiveState(_Socket, receivedFromEndPoint);
state.TaskCompletionSource = tcs;
#if NETSTANDARD1_6
- _Socket.ReceiveFromAsync(new System.ArraySegment<Byte>(state.Buffer), System.Net.Sockets.SocketFlags.None, state.EndPoint)
+ _Socket.ReceiveFromAsync(new ArraySegment<Byte>(state.Buffer),SocketFlags.None, state.EndPoint)
.ContinueWith((task, asyncState) =>
{
if (task.Status != TaskStatus.Faulted)
@@ -68,28 +62,36 @@ namespace Emby.Common.Implementations.Net
}
}, state);
#else
- _Socket.BeginReceiveFrom(state.Buffer, 0, state.Buffer.Length, System.Net.Sockets.SocketFlags.None, ref state.EndPoint, new AsyncCallback(this.ProcessResponse), state);
+ _Socket.BeginReceiveFrom(state.Buffer, 0, state.Buffer.Length, SocketFlags.None, ref state.EndPoint, new AsyncCallback(this.ProcessResponse), state);
#endif
return tcs.Task;
}
- public Task SendTo(byte[] messageData, IpEndPointInfo endPoint)
+ public Task SendAsync(byte[] buffer, int size, IpEndPointInfo endPoint)
{
ThrowIfDisposed();
- if (messageData == null) throw new ArgumentNullException("messageData");
+ if (buffer == null) throw new ArgumentNullException("messageData");
if (endPoint == null) throw new ArgumentNullException("endPoint");
#if NETSTANDARD1_6
- _Socket.SendTo(messageData, new System.Net.IPEndPoint(IPAddress.Parse(endPoint.IpAddress.ToString()), endPoint.Port));
+
+ if (size != buffer.Length)
+ {
+ byte[] copy = new byte[size];
+ Buffer.BlockCopy(buffer, 0, copy, 0, size);
+ buffer = copy;
+ }
+
+ _Socket.SendTo(buffer, new IPEndPoint(IPAddress.Parse(endPoint.IpAddress.ToString()), endPoint.Port));
return Task.FromResult(true);
#else
var taskSource = new TaskCompletionSource<bool>();
try
{
- _Socket.BeginSendTo(messageData, 0, messageData.Length, SocketFlags.None, new System.Net.IPEndPoint(IPAddress.Parse(endPoint.IpAddress.ToString()), endPoint.Port), result =>
+ _Socket.BeginSendTo(buffer, 0, size, SocketFlags.None, new System.Net.IPEndPoint(IPAddress.Parse(endPoint.IpAddress.ToString()), endPoint.Port), result =>
{
try
{
@@ -100,29 +102,10 @@ namespace Emby.Common.Implementations.Net
{
taskSource.TrySetException(ex);
}
- catch (ObjectDisposedException ex)
- {
- taskSource.TrySetException(ex);
- }
- catch (InvalidOperationException ex)
- {
- taskSource.TrySetException(ex);
- }
- catch (SecurityException ex)
- {
- taskSource.TrySetException(ex);
- }
+
}, null);
}
- catch (SocketException ex)
- {
- taskSource.TrySetException(ex);
- }
- catch (ObjectDisposedException ex)
- {
- taskSource.TrySetException(ex);
- }
- catch (SecurityException ex)
+ catch (Exception ex)
{
taskSource.TrySetException(ex);
}
@@ -151,7 +134,6 @@ namespace Emby.Common.Implementations.Net
#region Private Methods
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Exceptions via task methods should be reported by task completion source, so this should be ok.")]
private static void ProcessResponse(AsyncReceiveState state, Func<int> receiveData)
{
try
@@ -160,11 +142,11 @@ namespace Emby.Common.Implementations.Net
var ipEndPoint = state.EndPoint as IPEndPoint;
state.TaskCompletionSource.SetResult(
- new ReceivedUdpData()
+ new SocketReceiveResult()
{
Buffer = state.Buffer,
ReceivedBytes = bytesRead,
- ReceivedFrom = ToIpEndPointInfo(ipEndPoint)
+ RemoteEndPoint = ToIpEndPointInfo(ipEndPoint)
}
);
}
@@ -204,7 +186,6 @@ namespace Emby.Common.Implementations.Net
};
}
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Exceptions via task methods should be reported by task completion source, so this should be ok.")]
private void ProcessResponse(IAsyncResult asyncResult)
{
#if NET46
@@ -215,11 +196,11 @@ namespace Emby.Common.Implementations.Net
var ipEndPoint = state.EndPoint as IPEndPoint;
state.TaskCompletionSource.SetResult(
- new ReceivedUdpData()
+ new SocketReceiveResult
{
Buffer = state.Buffer,
ReceivedBytes = bytesRead,
- ReceivedFrom = ToIpEndPointInfo(ipEndPoint)
+ RemoteEndPoint = ToIpEndPointInfo(ipEndPoint)
}
);
}
@@ -247,7 +228,7 @@ namespace Emby.Common.Implementations.Net
private class AsyncReceiveState
{
- public AsyncReceiveState(System.Net.Sockets.Socket socket, EndPoint endPoint)
+ public AsyncReceiveState(Socket socket, EndPoint endPoint)
{
this.Socket = socket;
this.EndPoint = endPoint;
@@ -256,9 +237,9 @@ namespace Emby.Common.Implementations.Net
public EndPoint EndPoint;
public byte[] Buffer = new byte[8192];
- public System.Net.Sockets.Socket Socket { get; private set; }
+ public Socket Socket { get; private set; }
- public TaskCompletionSource<ReceivedUdpData> TaskCompletionSource { get; set; }
+ public TaskCompletionSource<SocketReceiveResult> TaskCompletionSource { get; set; }
}
diff --git a/Emby.Common.Implementations/Networking/BaseNetworkManager.cs b/Emby.Common.Implementations/Networking/BaseNetworkManager.cs
index bab340e27..10d0db968 100644
--- a/Emby.Common.Implementations/Networking/BaseNetworkManager.cs
+++ b/Emby.Common.Implementations/Networking/BaseNetworkManager.cs
@@ -8,6 +8,7 @@ using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Threading.Tasks;
using MediaBrowser.Model.Extensions;
+using MediaBrowser.Model.Net;
namespace Emby.Common.Implementations.Networking
{
@@ -21,7 +22,7 @@ namespace Emby.Common.Implementations.Networking
Logger = logger;
}
- private List<IPAddress> _localIpAddresses;
+ private List<IPAddress> _localIpAddresses;
private readonly object _localIpAddressSyncLock = new object();
/// <summary>
@@ -50,24 +51,24 @@ namespace Emby.Common.Implementations.Networking
return _localIpAddresses;
}
- private IEnumerable<IPAddress> GetLocalIpAddressesInternal()
+ private IEnumerable<IPAddress> GetLocalIpAddressesInternal()
{
var list = GetIPsDefault()
.ToList();
if (list.Count == 0)
{
- list.AddRange(GetLocalIpAddressesFallback().Result);
+ list.AddRange(GetLocalIpAddressesFallback().Result);
}
- return list.Where(FilterIpAddress).DistinctBy(i => i.ToString());
+ return list.Where(FilterIpAddress).DistinctBy(i => i.ToString());
}
- private bool FilterIpAddress(IPAddress address)
+ private bool FilterIpAddress(IPAddress address)
{
- var addressString = address.ToString ();
+ var addressString = address.ToString();
- if (addressString.StartsWith("169.", StringComparison.OrdinalIgnoreCase))
+ if (addressString.StartsWith("169.", StringComparison.OrdinalIgnoreCase))
{
return false;
}
@@ -155,12 +156,12 @@ namespace Emby.Common.Implementations.Networking
{
var prefix = addressString.Substring(0, lengthMatch);
- if (GetLocalIpAddresses().Any(i => i.ToString().StartsWith(prefix, StringComparison.OrdinalIgnoreCase)))
+ if (GetLocalIpAddresses().Any(i => i.ToString().StartsWith(prefix, StringComparison.OrdinalIgnoreCase)))
{
return true;
}
}
- }
+ }
else if (resolveHost)
{
Uri uri;
@@ -199,45 +200,50 @@ namespace Emby.Common.Implementations.Networking
return Dns.GetHostAddressesAsync(hostName);
}
- private List<IPAddress> GetIPsDefault()
- {
- NetworkInterface[] interfaces;
+ private List<IPAddress> GetIPsDefault()
+ {
+ NetworkInterface[] interfaces;
- try
- {
- interfaces = NetworkInterface.GetAllNetworkInterfaces();
- }
- catch (Exception ex)
- {
- Logger.ErrorException("Error in GetAllNetworkInterfaces", ex);
- return new List<IPAddress>();
- }
+ try
+ {
+ var validStatuses = new[] { OperationalStatus.Up, OperationalStatus.Unknown };
- return interfaces.SelectMany(network => {
+ interfaces = NetworkInterface.GetAllNetworkInterfaces()
+ .Where(i => validStatuses.Contains(i.OperationalStatus))
+ .ToArray();
+ }
+ catch (Exception ex)
+ {
+ Logger.ErrorException("Error in GetAllNetworkInterfaces", ex);
+ return new List<IPAddress>();
+ }
+
+ return interfaces.SelectMany(network =>
+ {
- try
- {
+ try
+ {
Logger.Debug("Querying interface: {0}. Type: {1}. Status: {2}", network.Name, network.NetworkInterfaceType, network.OperationalStatus);
- var properties = network.GetIPProperties();
+ var properties = network.GetIPProperties();
- return properties.UnicastAddresses
+ return properties.UnicastAddresses
.Where(i => i.IsDnsEligible)
.Select(i => i.Address)
.Where(i => i.AddressFamily == AddressFamily.InterNetwork)
- .ToList();
- }
- catch (Exception ex)
- {
- Logger.ErrorException("Error querying network interface", ex);
- return new List<IPAddress>();
- }
-
- }).DistinctBy(i => i.ToString())
- .ToList();
- }
-
- private async Task<IEnumerable<IPAddress>> GetLocalIpAddressesFallback()
+ .ToList();
+ }
+ catch (Exception ex)
+ {
+ Logger.ErrorException("Error querying network interface", ex);
+ return new List<IPAddress>();
+ }
+
+ }).DistinctBy(i => i.ToString())
+ .ToList();
+ }
+
+ private async Task<IEnumerable<IPAddress>> GetLocalIpAddressesFallback()
{
var host = await Dns.GetHostEntryAsync(Dns.GetHostName()).ConfigureAwait(false);
@@ -309,7 +315,7 @@ namespace Emby.Common.Implementations.Networking
string[] values = endpointstring.Split(new char[] { ':' });
IPAddress ipaddy;
int port = -1;
-
+
//check if we have an IPv6 or ports
if (values.Length <= 2) // ipv4 or hostname
{
@@ -382,5 +388,35 @@ namespace Emby.Common.Implementations.Networking
return hosts[0];
}
+
+ public IpAddressInfo ParseIpAddress(string ipAddress)
+ {
+ IpAddressInfo info;
+ if (TryParseIpAddress(ipAddress, out info))
+ {
+ return info;
+ }
+
+ throw new ArgumentException("Invalid ip address: " + ipAddress);
+ }
+
+ public bool TryParseIpAddress(string ipAddress, out IpAddressInfo ipAddressInfo)
+ {
+ IPAddress address;
+ if (IPAddress.TryParse(ipAddress, out address))
+ {
+
+ ipAddressInfo = new IpAddressInfo
+ {
+ Address = address.ToString(),
+ IsIpv6 = address.AddressFamily == AddressFamily.InterNetworkV6
+ };
+
+ return true;
+ }
+
+ ipAddressInfo = null;
+ return false;
+ }
}
}
diff --git a/Emby.Common.Implementations/Serialization/XmlSerializer.cs b/Emby.Common.Implementations/Serialization/XmlSerializer.cs
index aea63a57e..3583f998e 100644
--- a/Emby.Common.Implementations/Serialization/XmlSerializer.cs
+++ b/Emby.Common.Implementations/Serialization/XmlSerializer.cs
@@ -4,6 +4,7 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Xml;
+using System.Xml.Serialization;
using MediaBrowser.Common.IO;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
@@ -13,12 +14,12 @@ namespace Emby.Common.Implementations.Serialization
/// <summary>
/// Provides a wrapper around third party xml serialization.
/// </summary>
- public class XmlSerializer : IXmlSerializer
+ public class MyXmlSerializer : IXmlSerializer
{
private readonly IFileSystem _fileSystem;
private readonly ILogger _logger;
- public XmlSerializer(IFileSystem fileSystem, ILogger logger)
+ public MyXmlSerializer(IFileSystem fileSystem, ILogger logger)
{
_fileSystem = fileSystem;
_logger = logger;
@@ -26,18 +27,18 @@ namespace Emby.Common.Implementations.Serialization
// Need to cache these
// http://dotnetcodebox.blogspot.com/2013/01/xmlserializer-class-may-result-in.html
- private readonly Dictionary<string, System.Xml.Serialization.XmlSerializer> _serializers =
- new Dictionary<string, System.Xml.Serialization.XmlSerializer>();
+ private readonly Dictionary<string, XmlSerializer> _serializers =
+ new Dictionary<string, XmlSerializer>();
- private System.Xml.Serialization.XmlSerializer GetSerializer(Type type)
+ private XmlSerializer GetSerializer(Type type)
{
var key = type.FullName;
lock (_serializers)
{
- System.Xml.Serialization.XmlSerializer serializer;
+ XmlSerializer serializer;
if (!_serializers.TryGetValue(key, out serializer))
{
- serializer = new System.Xml.Serialization.XmlSerializer(type);
+ serializer = new XmlSerializer(type);
_serializers[key] = serializer;
}
return serializer;
@@ -80,7 +81,7 @@ namespace Emby.Common.Implementations.Serialization
#if NET46
using (var writer = new XmlTextWriter(stream, null))
{
- writer.Formatting = System.Xml.Formatting.Indented;
+ writer.Formatting = Formatting.Indented;
SerializeToWriter(obj, writer);
}
#else
diff --git a/Emby.Common.Implementations/project.json b/Emby.Common.Implementations/project.json
index dc96f5726..2b2357e38 100644
--- a/Emby.Common.Implementations/project.json
+++ b/Emby.Common.Implementations/project.json
@@ -12,15 +12,14 @@
"System.IO": "4.0.0.0",
"System.Net": "4.0.0.0",
"System.Net.Http": "4.0.0.0",
- "System.Net.Http.WebRequest": "4.0.0.0",
"System.Net.Primitives": "4.0.0.0",
+ "System.Net.Http.WebRequest": "4.0.0.0",
"System.Runtime": "4.0.0.0",
"System.Runtime.Extensions": "4.0.0.0",
"System.Text.Encoding": "4.0.0.0",
"System.Threading": "4.0.0.0",
"System.Threading.Tasks": "4.0.0.0",
- "System.Xml": "4.0.0.0",
- "System.Xml.Serialization": "4.0.0.0"
+ "System.Xml.ReaderWriter": "4.0.0"
},
"dependencies": {
"SimpleInjector": "3.2.4",
@@ -30,7 +29,8 @@
},
"MediaBrowser.Common": {
"target": "project"
- } }
+ }
+ }
},
"netstandard1.6": {
"imports": "dnxcore50",
@@ -40,6 +40,7 @@
"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",