From f07af448fa11330db93dd7ddcabac37ef9e014c7 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 24 May 2017 15:12:55 -0400 Subject: update main projects --- Emby.Common.Implementations/BaseApplicationHost.cs | 50 +-- .../Diagnostics/CommonProcess.cs | 2 - .../Emby.Common.Implementations.csproj | 381 +++++++++++++++++++++ .../Emby.Common.Implementations.xproj | 23 -- .../EnvironmentInfo/EnvironmentInfo.cs | 46 +-- .../HttpClientManager/HttpClientManager.cs | 36 -- Emby.Common.Implementations/Net/SocketFactory.cs | 11 +- Emby.Common.Implementations/Net/UdpSocket.cs | 169 ++------- .../Properties/AssemblyInfo.cs | 23 +- .../Reflection/AssemblyInfo.cs | 6 - .../Serialization/XmlSerializer.cs | 9 +- .../Xml/XmlReaderSettingsFactory.cs | 2 - Emby.Common.Implementations/packages.config | 7 + Emby.Common.Implementations/project.json | 71 ---- 14 files changed, 452 insertions(+), 384 deletions(-) create mode 100644 Emby.Common.Implementations/Emby.Common.Implementations.csproj delete mode 100644 Emby.Common.Implementations/Emby.Common.Implementations.xproj create mode 100644 Emby.Common.Implementations/packages.config delete mode 100644 Emby.Common.Implementations/project.json (limited to 'Emby.Common.Implementations') diff --git a/Emby.Common.Implementations/BaseApplicationHost.cs b/Emby.Common.Implementations/BaseApplicationHost.cs index d3d8672be..dd4be9aae 100644 --- a/Emby.Common.Implementations/BaseApplicationHost.cs +++ b/Emby.Common.Implementations/BaseApplicationHost.cs @@ -39,10 +39,6 @@ using MediaBrowser.Model.System; using MediaBrowser.Model.Tasks; using MediaBrowser.Model.Threading; -#if NETSTANDARD1_6 -using System.Runtime.Loader; -#endif - namespace Emby.Common.Implementations { /// @@ -306,7 +302,6 @@ namespace Emby.Common.Implementations builder.AppendLine(string.Format("Command line: {0}", string.Join(" ", Environment.GetCommandLineArgs()))); -#if NET46 builder.AppendLine(string.Format("Operating system: {0}", Environment.OSVersion)); builder.AppendLine(string.Format("64-Bit OS: {0}", Environment.Is64BitOperatingSystem)); builder.AppendLine(string.Format("64-Bit Process: {0}", Environment.Is64BitProcess)); @@ -320,7 +315,6 @@ namespace Emby.Common.Implementations builder.AppendLine("Mono: " + displayName.Invoke(null, null)); } } -#endif builder.AppendLine(string.Format("Processor count: {0}", Environment.ProcessorCount)); builder.AppendLine(string.Format("Program data path: {0}", appPaths.ProgramDataPath)); @@ -336,9 +330,7 @@ namespace Emby.Common.Implementations try { // Increase the max http request limit -#if NET46 ServicePointManager.DefaultConnectionLimit = Math.Max(96, ServicePointManager.DefaultConnectionLimit); -#endif } catch (Exception ex) { @@ -436,7 +428,6 @@ namespace Emby.Common.Implementations if (assemblyPlugin != null) { -#if NET46 var assembly = plugin.GetType().Assembly; var assemblyName = assembly.GetName(); @@ -447,21 +438,7 @@ namespace Emby.Common.Implementations var assemblyFilePath = Path.Combine(ApplicationPaths.PluginsPath, assemblyFileName); assemblyPlugin.SetAttributes(assemblyFilePath, assemblyFileName, assemblyName.Version, assemblyId); -#elif NETSTANDARD1_6 - var typeInfo = plugin.GetType().GetTypeInfo(); - var assembly = typeInfo.Assembly; - var assemblyName = assembly.GetName(); - - var attribute = (GuidAttribute)assembly.GetCustomAttribute(typeof(GuidAttribute)); - var assemblyId = new Guid(attribute.Value); - - var assemblyFileName = assemblyName.Name + ".dll"; - var assemblyFilePath = Path.Combine(ApplicationPaths.PluginsPath, assemblyFileName); - - assemblyPlugin.SetAttributes(assemblyFilePath, assemblyFileName, assemblyName.Version, assemblyId); -#else -return null; -#endif + return null; } var isFirstRun = !File.Exists(plugin.ConfigurationFilePath); @@ -492,17 +469,7 @@ return null; AllConcreteTypes = assemblies .SelectMany(GetTypes) - .Where(t => - { -#if NET46 - return t.IsClass && !t.IsAbstract && !t.IsInterface && !t.IsGenericType; -#endif -#if NETSTANDARD1_6 - var typeInfo = t.GetTypeInfo(); - return typeInfo.IsClass && !typeInfo.IsAbstract && !typeInfo.IsInterface && !typeInfo.IsGenericType; -#endif - return false; - }) + .Where(t => t.IsClass && !t.IsAbstract && !t.IsInterface && !t.IsGenericType) .ToArray(); } @@ -717,13 +684,7 @@ return null; { try { -#if NET46 return Assembly.Load(File.ReadAllBytes(file)); -#elif NETSTANDARD1_6 - - return AssemblyLoadContext.Default.LoadFromStream(new MemoryStream(File.ReadAllBytes(file))); -#endif - return null; } catch (Exception ex) { @@ -742,14 +703,7 @@ return null; { var currentType = typeof(T); -#if NET46 return AllConcreteTypes.Where(currentType.IsAssignableFrom); -#elif NETSTANDARD1_6 - var currentTypeInfo = currentType.GetTypeInfo(); - - return AllConcreteTypes.Where(currentTypeInfo.IsAssignableFrom); -#endif - return new List(); } /// diff --git a/Emby.Common.Implementations/Diagnostics/CommonProcess.cs b/Emby.Common.Implementations/Diagnostics/CommonProcess.cs index 462345ced..f6ca6cf9c 100644 --- a/Emby.Common.Implementations/Diagnostics/CommonProcess.cs +++ b/Emby.Common.Implementations/Diagnostics/CommonProcess.cs @@ -31,14 +31,12 @@ namespace Emby.Common.Implementations.Diagnostics RedirectStandardOutput = options.RedirectStandardOutput }; -#if NET46 startInfo.ErrorDialog = options.ErrorDialog; if (options.IsHidden) { startInfo.WindowStyle = ProcessWindowStyle.Hidden; } -#endif _process = new Process { diff --git a/Emby.Common.Implementations/Emby.Common.Implementations.csproj b/Emby.Common.Implementations/Emby.Common.Implementations.csproj new file mode 100644 index 000000000..6e818b163 --- /dev/null +++ b/Emby.Common.Implementations/Emby.Common.Implementations.csproj @@ -0,0 +1,381 @@ + + + + + Debug + AnyCPU + {1E37A338-9F57-4B70-BD6D-BB9C591E319B} + Library + Properties + Emby.Common.Implementations + Emby.Common.Implementations + v4.6.2 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\NLog.4.4.3\lib\net45\NLog.dll + True + + + ..\packages\ServiceStack.Text.4.5.8\lib\net45\ServiceStack.Text.dll + True + + + ..\packages\SharpCompress.0.14.0\lib\net45\SharpCompress.dll + True + + + ..\packages\SimpleInjector.4.0.7\lib\net45\SimpleInjector.dll + True + + + + + + + + + + + + + Properties\SharedVersion.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {9142eefa-7570-41e1-bfcc-468bb571af2f} + MediaBrowser.Common + + + {7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b} + MediaBrowser.Model + + + + + + + + \ No newline at end of file diff --git a/Emby.Common.Implementations/Emby.Common.Implementations.xproj b/Emby.Common.Implementations/Emby.Common.Implementations.xproj deleted file mode 100644 index 5bb6e4e58..000000000 --- a/Emby.Common.Implementations/Emby.Common.Implementations.xproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 5a27010a-09c6-4e86-93ea-437484c10917 - Emby.Common.Implementations - .\obj - .\bin\ - v4.5.2 - - - 2.0 - - - - - - - \ No newline at end of file diff --git a/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs b/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs index 27fc642f1..89aa787b5 100644 --- a/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs +++ b/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs @@ -10,7 +10,7 @@ namespace Emby.Common.Implementations.EnvironmentInfo { public class EnvironmentInfo : IEnvironmentInfo { - public MediaBrowser.Model.System.Architecture? CustomArchitecture { get; set; } + public Architecture? CustomArchitecture { get; set; } public MediaBrowser.Model.System.OperatingSystem? CustomOperatingSystem { get; set; } public virtual MediaBrowser.Model.System.OperatingSystem OperatingSystem @@ -22,7 +22,6 @@ namespace Emby.Common.Implementations.EnvironmentInfo return CustomOperatingSystem.Value; } -#if NET46 switch (Environment.OSVersion.Platform) { case PlatformID.MacOSX: @@ -32,20 +31,7 @@ namespace Emby.Common.Implementations.EnvironmentInfo 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; } } @@ -54,12 +40,7 @@ namespace Emby.Common.Implementations.EnvironmentInfo { get { -#if NET46 return Environment.OSVersion.Platform.ToString(); -#elif NETSTANDARD1_6 - return System.Runtime.InteropServices.RuntimeInformation.OSDescription; -#endif - return "Operating System"; } } @@ -67,12 +48,7 @@ namespace Emby.Common.Implementations.EnvironmentInfo { 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"; } } @@ -84,7 +60,7 @@ namespace Emby.Common.Implementations.EnvironmentInfo } } - public MediaBrowser.Model.System.Architecture SystemArchitecture + public Architecture SystemArchitecture { get { @@ -92,22 +68,8 @@ namespace Emby.Common.Implementations.EnvironmentInfo { 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/HttpClientManager/HttpClientManager.cs b/Emby.Common.Implementations/HttpClientManager/HttpClientManager.cs index eb9bc1bd0..c2a310c0e 100644 --- a/Emby.Common.Implementations/HttpClientManager/HttpClientManager.cs +++ b/Emby.Common.Implementations/HttpClientManager/HttpClientManager.cs @@ -66,13 +66,11 @@ namespace Emby.Common.Implementations.HttpClientManager _appPaths = appPaths; _defaultUserAgentFn = defaultUserAgentFn; -#if NET46 // http://stackoverflow.com/questions/566437/http-post-returns-the-error-417-expectation-failed-c ServicePointManager.Expect100Continue = false; // Trakt requests sometimes fail without this ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls; -#endif } /// @@ -129,7 +127,6 @@ namespace Emby.Common.Implementations.HttpClientManager private void AddIpv4Option(HttpWebRequest request, HttpRequestOptions options) { -#if NET46 request.ServicePoint.BindIPEndPointDelegate = (servicePount, remoteEndPoint, retryCount) => { if (remoteEndPoint.AddressFamily == AddressFamily.InterNetwork) @@ -138,7 +135,6 @@ namespace Emby.Common.Implementations.HttpClientManager } throw new InvalidOperationException("no IPv4 address"); }; -#endif } private WebRequest GetRequest(HttpRequestOptions options, string method) @@ -165,7 +161,6 @@ namespace Emby.Common.Implementations.HttpClientManager AddRequestHeaders(httpWebRequest, options); -#if NET46 if (options.EnableHttpCompression) { if (options.DecompressionMethod.HasValue) @@ -183,48 +178,33 @@ namespace Emby.Common.Implementations.HttpClientManager { httpWebRequest.AutomaticDecompression = DecompressionMethods.None; } -#endif } -#if NET46 request.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.BypassCache); -#endif if (httpWebRequest != null) { if (options.EnableKeepAlive) { -#if NET46 httpWebRequest.KeepAlive = true; -#endif } } request.Method = method; -#if NET46 request.Timeout = options.TimeoutMs; -#endif if (httpWebRequest != null) { if (!string.IsNullOrEmpty(options.Host)) { -#if NET46 httpWebRequest.Host = options.Host; -#elif NETSTANDARD1_6 - httpWebRequest.Headers["Host"] = options.Host; -#endif } if (!string.IsNullOrEmpty(options.Referer)) { -#if NET46 httpWebRequest.Referer = options.Referer; -#elif NETSTANDARD1_6 - httpWebRequest.Headers["Referer"] = options.Referer; -#endif } } @@ -235,9 +215,7 @@ namespace Emby.Common.Implementations.HttpClientManager { request.Credentials = GetCredential(url, parts[0], parts[1]); // TODO: .net core ?? -#if NET46 request.PreAuthenticate = true; -#endif } } @@ -269,11 +247,7 @@ namespace Emby.Common.Implementations.HttpClientManager } else { -#if NET46 request.Headers.Set(header.Key, header.Value); -#elif NETSTANDARD1_6 - request.Headers[header.Key] = header.Value; -#endif } } @@ -285,11 +259,7 @@ namespace Emby.Common.Implementations.HttpClientManager private void SetUserAgent(HttpWebRequest request, string userAgent) { -#if NET46 request.UserAgent = userAgent; -#elif NETSTANDARD1_6 - request.Headers["User-Agent"] = userAgent; -#endif } /// @@ -465,9 +435,7 @@ namespace Emby.Common.Implementations.HttpClientManager httpWebRequest.ContentType = options.RequestContentType ?? "application/x-www-form-urlencoded"; -#if NET46 httpWebRequest.ContentLength = bytes.Length; -#endif (await httpWebRequest.GetRequestStreamAsync().ConfigureAwait(false)).Write(bytes, 0, bytes.Length); } catch (Exception ex) @@ -950,7 +918,6 @@ namespace Emby.Common.Implementations.HttpClientManager private Task GetResponseAsync(WebRequest request, TimeSpan timeout) { -#if NET46 var taskCompletion = new TaskCompletionSource(); Task asyncTask = Task.Factory.FromAsync(request.BeginGetResponse, request.EndGetResponse, null); @@ -963,9 +930,6 @@ namespace Emby.Common.Implementations.HttpClientManager asyncTask.ContinueWith(callback.OnError, TaskContinuationOptions.OnlyOnFaulted); return taskCompletion.Task; -#endif - - return request.GetResponseAsync(); } private static void TimeoutCallback(object state, bool timedOut) diff --git a/Emby.Common.Implementations/Net/SocketFactory.cs b/Emby.Common.Implementations/Net/SocketFactory.cs index 39f236afa..3562a8644 100644 --- a/Emby.Common.Implementations/Net/SocketFactory.cs +++ b/Emby.Common.Implementations/Net/SocketFactory.cs @@ -188,16 +188,7 @@ namespace Emby.Common.Implementations.Net try { -#if NET46 - retVal.ExclusiveAddressUse = false; -#else - // The ExclusiveAddressUse acceptSocket option is a Windows-specific option that, when set to "true," tells Windows not to allow another acceptSocket to use the same local address as this acceptSocket - // See https://github.com/dotnet/corefx/pull/11509 for more details - if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) - { - retVal.ExclusiveAddressUse = false; - } -#endif + retVal.ExclusiveAddressUse = false; //retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true); retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, multicastTimeToLive); diff --git a/Emby.Common.Implementations/Net/UdpSocket.cs b/Emby.Common.Implementations/Net/UdpSocket.cs index f9181eb6a..678cf6f03 100644 --- a/Emby.Common.Implementations/Net/UdpSocket.cs +++ b/Emby.Common.Implementations/Net/UdpSocket.cs @@ -116,129 +116,64 @@ namespace Emby.Common.Implementations.Net private set; } - public Task ReceiveAsync(CancellationToken cancellationToken) + private readonly AsyncCallback _defaultAsyncCallback = (i) => { }; + + public IAsyncResult BeginReceive(byte[] buffer, int offset, int count, AsyncCallback callback) { - ThrowIfDisposed(); - var tcs = new TaskCompletionSource(); EndPoint receivedFromEndPoint = new IPEndPoint(IPAddress.Any, 0); - var state = new AsyncReceiveState(_Socket, receivedFromEndPoint); - state.TaskCompletionSource = tcs; - - cancellationToken.Register(() => tcs.TrySetCanceled()); - - _receiveSocketAsyncEventArgs.RemoteEndPoint = receivedFromEndPoint; - _currentReceiveTaskCompletionSource = tcs; - - try - { - var willRaiseEvent = _Socket.ReceiveFromAsync(_receiveSocketAsyncEventArgs); - - if (!willRaiseEvent) - { - _receiveSocketAsyncEventArgs_Completed(this, _receiveSocketAsyncEventArgs); - } - } - catch (Exception ex) - { - tcs.TrySetException(ex); - } - - return tcs.Task; + return _Socket.BeginReceiveFrom(buffer, offset, count, SocketFlags.None, ref receivedFromEndPoint, callback, buffer); } - public Task SendAsync(byte[] buffer, int size, IpEndPointInfo endPoint, CancellationToken cancellationToken) + public SocketReceiveResult EndReceive(IAsyncResult result) { - ThrowIfDisposed(); - - if (buffer == null) throw new ArgumentNullException("messageData"); - if (endPoint == null) throw new ArgumentNullException("endPoint"); + IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0); + EndPoint remoteEndPoint = (EndPoint)sender; - var ipEndPoint = NetworkManager.ToIPEndPoint(endPoint); + var receivedBytes = _Socket.EndReceiveFrom(result, ref remoteEndPoint); -#if NETSTANDARD1_6 + var buffer = (byte[]) result.AsyncState; - if (size != buffer.Length) + return new SocketReceiveResult { - byte[] copy = new byte[size]; - Buffer.BlockCopy(buffer, 0, copy, 0, size); - buffer = copy; - } - - cancellationToken.ThrowIfCancellationRequested(); - - _Socket.SendTo(buffer, ipEndPoint); - return Task.FromResult(true); -#else - var taskSource = new TaskCompletionSource(); - - try - { - _Socket.BeginSendTo(buffer, 0, size, SocketFlags.None, ipEndPoint, result => - { - if (cancellationToken.IsCancellationRequested) - { - taskSource.TrySetCanceled(); - return; - } - try - { - _Socket.EndSend(result); - taskSource.TrySetResult(true); - } - catch (Exception ex) - { - taskSource.TrySetException(ex); - } - - }, null); - } - catch (Exception ex) - { - taskSource.TrySetException(ex); - } - - return taskSource.Task; -#endif - //ThrowIfDisposed(); - - //if (buffer == null) throw new ArgumentNullException("messageData"); - //if (endPoint == null) throw new ArgumentNullException("endPoint"); - - //cancellationToken.ThrowIfCancellationRequested(); + ReceivedBytes = receivedBytes, + RemoteEndPoint = ToIpEndPointInfo((IPEndPoint)remoteEndPoint), + Buffer = buffer, + LocalIPAddress = LocalIPAddress + }; + } - //var tcs = new TaskCompletionSource(); + public Task ReceiveAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + var result = BeginReceive(buffer, offset, count, _defaultAsyncCallback); - //cancellationToken.Register(() => tcs.TrySetCanceled()); + return Task.Factory.FromAsync(result, EndReceive); + } - //_sendSocketAsyncEventArgs.SetBuffer(buffer, 0, size); - //_sendSocketAsyncEventArgs.RemoteEndPoint = NetworkManager.ToIPEndPoint(endPoint); - //_currentSendTaskCompletionSource = tcs; + public Task ReceiveAsync(CancellationToken cancellationToken) + { + var buffer = new byte[8192]; - //var willRaiseEvent = _Socket.SendAsync(_sendSocketAsyncEventArgs); + return ReceiveAsync(buffer, 0, buffer.Length, cancellationToken); + } - //if (!willRaiseEvent) - //{ - // _sendSocketAsyncEventArgs_Completed(this, _sendSocketAsyncEventArgs); - //} + public Task SendToAsync(byte[] buffer, int offset, int size, IpEndPointInfo endPoint, CancellationToken cancellationToken) + { + var result = BeginSendTo(buffer, offset, size, endPoint, _defaultAsyncCallback, null); - //return tcs.Task; + return Task.Factory.FromAsync(result, EndSendTo); } - public async Task SendWithLockAsync(byte[] buffer, int size, IpEndPointInfo endPoint, CancellationToken cancellationToken) + public IAsyncResult BeginSendTo(byte[] buffer, int offset, int size, IpEndPointInfo endPoint, AsyncCallback callback, object state) { - ThrowIfDisposed(); + var ipEndPoint = NetworkManager.ToIPEndPoint(endPoint); - //await _sendLock.WaitAsync(cancellationToken).ConfigureAwait(false); + return _Socket.BeginSendTo(buffer, offset, size, SocketFlags.None, ipEndPoint, callback, state); + } - try - { - await SendAsync(buffer, size, endPoint, cancellationToken).ConfigureAwait(false); - } - finally - { - //_sendLock.Release(); - } + public int EndSendTo(IAsyncResult result) + { + return _Socket.EndSendTo(result); } protected override void Dispose(bool disposing) @@ -274,36 +209,6 @@ namespace Emby.Common.Implementations.Net return NetworkManager.ToIpEndPointInfo(endpoint); } - private void ProcessResponse(IAsyncResult asyncResult) - { -#if NET46 - var state = asyncResult.AsyncState as AsyncReceiveState; - try - { - var bytesRead = state.Socket.EndReceiveFrom(asyncResult, ref state.RemoteEndPoint); - - var ipEndPoint = state.RemoteEndPoint as IPEndPoint; - state.TaskCompletionSource.SetResult( - new SocketReceiveResult - { - Buffer = state.Buffer, - ReceivedBytes = bytesRead, - RemoteEndPoint = ToIpEndPointInfo(ipEndPoint), - LocalIPAddress = LocalIPAddress - } - ); - } - catch (ObjectDisposedException) - { - state.TaskCompletionSource.SetCanceled(); - } - catch (Exception ex) - { - state.TaskCompletionSource.SetException(ex); - } -#endif - } - private class AsyncReceiveState { public AsyncReceiveState(Socket socket, EndPoint remoteEndPoint) diff --git a/Emby.Common.Implementations/Properties/AssemblyInfo.cs b/Emby.Common.Implementations/Properties/AssemblyInfo.cs index 1a5abcb27..787f18997 100644 --- a/Emby.Common.Implementations/Properties/AssemblyInfo.cs +++ b/Emby.Common.Implementations/Properties/AssemblyInfo.cs @@ -2,18 +2,33 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. +[assembly: AssemblyTitle("Emby.Common.Implementations")] +[assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Emby.Common.Implementations")] +[assembly: AssemblyCopyright("Copyright © 2017")] [assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] -// 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 +// 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)] // The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5a27010a-09c6-4e86-93ea-437484c10917")] +[assembly: Guid("1e37a338-9f57-4b70-bd6d-bb9c591e319b")] + +// 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 diff --git a/Emby.Common.Implementations/Reflection/AssemblyInfo.cs b/Emby.Common.Implementations/Reflection/AssemblyInfo.cs index 7a92f02d6..87821bf7a 100644 --- a/Emby.Common.Implementations/Reflection/AssemblyInfo.cs +++ b/Emby.Common.Implementations/Reflection/AssemblyInfo.cs @@ -9,18 +9,12 @@ namespace Emby.Common.Implementations.Reflection { public Stream GetManifestResourceStream(Type type, string resource) { -#if NET46 return type.Assembly.GetManifestResourceStream(resource); -#endif - return type.GetTypeInfo().Assembly.GetManifestResourceStream(resource); } public string[] GetManifestResourceNames(Type type) { -#if NET46 return type.Assembly.GetManifestResourceNames(); -#endif - return type.GetTypeInfo().Assembly.GetManifestResourceNames(); } public Assembly[] GetCurrentAssemblies() diff --git a/Emby.Common.Implementations/Serialization/XmlSerializer.cs b/Emby.Common.Implementations/Serialization/XmlSerializer.cs index 3583f998e..ad2708387 100644 --- a/Emby.Common.Implementations/Serialization/XmlSerializer.cs +++ b/Emby.Common.Implementations/Serialization/XmlSerializer.cs @@ -78,18 +78,11 @@ namespace Emby.Common.Implementations.Serialization /// The stream. public void SerializeToStream(object obj, Stream stream) { -#if NET46 - using (var writer = new XmlTextWriter(stream, null)) + using (var writer = new XmlTextWriter(stream, null)) { writer.Formatting = Formatting.Indented; SerializeToWriter(obj, writer); } -#else - using (var writer = XmlWriter.Create(stream)) - { - SerializeToWriter(obj, writer); - } -#endif } /// diff --git a/Emby.Common.Implementations/Xml/XmlReaderSettingsFactory.cs b/Emby.Common.Implementations/Xml/XmlReaderSettingsFactory.cs index 806290cf4..35c266cdb 100644 --- a/Emby.Common.Implementations/Xml/XmlReaderSettingsFactory.cs +++ b/Emby.Common.Implementations/Xml/XmlReaderSettingsFactory.cs @@ -11,9 +11,7 @@ namespace Emby.Common.Implementations.Xml if (!enableValidation) { -#if NET46 settings.ValidationType = ValidationType.None; -#endif } return settings; diff --git a/Emby.Common.Implementations/packages.config b/Emby.Common.Implementations/packages.config new file mode 100644 index 000000000..18022eb2e --- /dev/null +++ b/Emby.Common.Implementations/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Emby.Common.Implementations/project.json b/Emby.Common.Implementations/project.json deleted file mode 100644 index ff60c740e..000000000 --- a/Emby.Common.Implementations/project.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "version": "1.0.0-*", - - "dependencies": { - - }, - - "frameworks": { - "net46": { - "frameworkAssemblies": { - "System.Collections": "4.0.0.0", - "System.IO": "4.0.0.0", - "System.Net": "4.0.0.0", - "System.Net.Http": "4.0.0.0", - "System.Net.Primitives": "4.0.0.0", - "System.Net.Http.WebRequest": "4.0.0.0", - "System.Reflection": "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.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.1", - "System.IO.FileSystem.DriveInfo": "4.3.0", - "System.Diagnostics.Process": "4.3.0", - "System.Threading.Timer": "4.3.0", - "System.Net.Requests": "4.3.0", - "System.Xml.ReaderWriter": "4.3.0", - "System.Xml.XmlSerializer": "4.3.0", - "System.Net.Http": "4.3.2", - "System.Net.Primitives": "4.3.0", - "System.Net.Sockets": "4.3.0", - "System.Net.NetworkInformation": "4.3.0", - "System.Net.NameResolution": "4.3.0", - "System.Runtime.InteropServices.RuntimeInformation": "4.3.0", - "System.Reflection": "4.3.0", - "System.Reflection.Primitives": "4.3.0", - "System.Runtime.Loader": "4.3.0", - "SimpleInjector": "3.2.4", - "ServiceStack.Text.Core": "1.0.27", - "NLog": "4.4.0-betaV15", - "sharpcompress": "0.14.0", - "System.AppDomain": "2.0.11", - "MediaBrowser.Model": { - "target": "project" - }, - "MediaBrowser.Common": { - "target": "project" - } - } - } - } -} -- cgit v1.2.3