diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-11-08 13:44:23 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-11-08 13:44:23 -0500 |
| commit | a8b340cbb29dbcf7fd5d101e640d66470c6d32bf (patch) | |
| tree | a626c151e9ccb8809dd6d667fb9146fe4bb3ffea /MediaBrowser.Model | |
| parent | 05a5ce58a9293f6669960c735911e9455c5d8188 (diff) | |
update portable projects
Diffstat (limited to 'MediaBrowser.Model')
| -rw-r--r-- | MediaBrowser.Model/Cryptography/ICryptoProvider.cs | 13 | ||||
| -rw-r--r-- | MediaBrowser.Model/Cryptography/ICryptographyProvider.cs | 14 | ||||
| -rw-r--r-- | MediaBrowser.Model/IO/IMemoryStreamFactory.cs (renamed from MediaBrowser.Model/IO/IMemoryStreamProvider.cs) | 3 | ||||
| -rw-r--r-- | MediaBrowser.Model/MediaBrowser.Model.csproj | 8 | ||||
| -rw-r--r-- | MediaBrowser.Model/Net/ISocket.cs | 16 | ||||
| -rw-r--r-- | MediaBrowser.Model/Net/ISocketFactory.cs | 14 | ||||
| -rw-r--r-- | MediaBrowser.Model/Net/IpAddressInfo.cs | 29 | ||||
| -rw-r--r-- | MediaBrowser.Model/Net/IpEndPointInfo.cs | 14 | ||||
| -rw-r--r-- | MediaBrowser.Model/Services/IHasRequestFilter.cs | 13 | ||||
| -rw-r--r-- | MediaBrowser.Model/Services/IHttpResult.cs | 47 | ||||
| -rw-r--r-- | MediaBrowser.Model/Services/IRequest.cs | 10 | ||||
| -rw-r--r-- | MediaBrowser.Model/Services/QueryParamCollection.cs | 31 | ||||
| -rw-r--r-- | MediaBrowser.Model/Text/ITextEncoding.cs | 10 | ||||
| -rw-r--r-- | MediaBrowser.Model/TextEncoding/IEncoding.cs | 12 |
14 files changed, 173 insertions, 61 deletions
diff --git a/MediaBrowser.Model/Cryptography/ICryptoProvider.cs b/MediaBrowser.Model/Cryptography/ICryptoProvider.cs new file mode 100644 index 000000000..7a82dee52 --- /dev/null +++ b/MediaBrowser.Model/Cryptography/ICryptoProvider.cs @@ -0,0 +1,13 @@ +using System; +using System.IO; + +namespace MediaBrowser.Model.Cryptography +{ + public interface ICryptoProvider + { + Guid GetMD5(string str); + byte[] ComputeMD5(Stream str); + byte[] ComputeMD5(byte[] bytes); + byte[] ComputeSHA1(byte[] bytes); + } +}
\ No newline at end of file diff --git a/MediaBrowser.Model/Cryptography/ICryptographyProvider.cs b/MediaBrowser.Model/Cryptography/ICryptographyProvider.cs deleted file mode 100644 index a3f86f9e2..000000000 --- a/MediaBrowser.Model/Cryptography/ICryptographyProvider.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.IO; - -namespace MediaBrowser.Model.Cryptography -{ - public interface ICryptographyProvider - { - Guid GetMD5(string str); - byte[] GetMD5Bytes(string str); - byte[] GetSHA1Bytes(byte[] bytes); - byte[] GetMD5Bytes(Stream str); - byte[] GetMD5Bytes(byte[] bytes); - } -}
\ No newline at end of file diff --git a/MediaBrowser.Model/IO/IMemoryStreamProvider.cs b/MediaBrowser.Model/IO/IMemoryStreamFactory.cs index 82a758d9a..f4f174643 100644 --- a/MediaBrowser.Model/IO/IMemoryStreamProvider.cs +++ b/MediaBrowser.Model/IO/IMemoryStreamFactory.cs @@ -2,10 +2,11 @@ namespace MediaBrowser.Model.IO { - public interface IMemoryStreamProvider + public interface IMemoryStreamFactory { MemoryStream CreateNew(); MemoryStream CreateNew(int capacity); MemoryStream CreateNew(byte[] buffer); + bool TryGetBuffer(MemoryStream stream, out byte[] buffer); } } diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 52e477b1a..ee7582619 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -100,7 +100,7 @@ <Compile Include="Connect\PinExchangeResult.cs" /> <Compile Include="Connect\PinStatusResult.cs" /> <Compile Include="Connect\UserLinkType.cs" /> - <Compile Include="Cryptography\ICryptographyProvider.cs" /> + <Compile Include="Cryptography\ICryptoProvider.cs" /> <Compile Include="Devices\DeviceOptions.cs" /> <Compile Include="Devices\DeviceQuery.cs" /> <Compile Include="Devices\LocalFileInfo.cs" /> @@ -138,17 +138,19 @@ <Compile Include="Dto\NameIdPair.cs" /> <Compile Include="Dto\NameValuePair.cs" /> <Compile Include="Net\IpEndPointInfo.cs" /> + <Compile Include="Net\ISocket.cs" /> <Compile Include="Net\ISocketFactory.cs" /> <Compile Include="Net\IUdpSocket.cs" /> <Compile Include="Net\SocketReceiveResult.cs" /> + <Compile Include="Services\IHttpResult.cs" /> <Compile Include="System\IEnvironmentInfo.cs" /> - <Compile Include="TextEncoding\IEncoding.cs" /> + <Compile Include="Text\ITextEncoding.cs" /> <Compile Include="Extensions\LinqExtensions.cs" /> <Compile Include="FileOrganization\SmartMatchInfo.cs" /> <Compile Include="Health\IHealthMonitor.cs" /> <Compile Include="IO\FileSystemMetadata.cs" /> <Compile Include="IO\IFileSystem.cs" /> - <Compile Include="IO\IMemoryStreamProvider.cs" /> + <Compile Include="IO\IMemoryStreamFactory.cs" /> <Compile Include="IO\IShortcutHandler.cs" /> <Compile Include="IO\StreamDefaults.cs" /> <Compile Include="Globalization\ILocalizationManager.cs" /> diff --git a/MediaBrowser.Model/Net/ISocket.cs b/MediaBrowser.Model/Net/ISocket.cs new file mode 100644 index 000000000..371fbc567 --- /dev/null +++ b/MediaBrowser.Model/Net/ISocket.cs @@ -0,0 +1,16 @@ +using System; + +namespace MediaBrowser.Model.Net +{ + public interface ISocket : IDisposable + { + IpEndPointInfo LocalEndPoint { get; } + IpEndPointInfo RemoteEndPoint { get; } + void Close(); + void Shutdown(bool both); + void Listen(int backlog); + void Bind(IpEndPointInfo endpoint); + + void StartAccept(Action<ISocket> onAccept, Func<bool> isClosed); + } +} diff --git a/MediaBrowser.Model/Net/ISocketFactory.cs b/MediaBrowser.Model/Net/ISocketFactory.cs index 3f1ddf84f..599292ddf 100644 --- a/MediaBrowser.Model/Net/ISocketFactory.cs +++ b/MediaBrowser.Model/Net/ISocketFactory.cs @@ -27,5 +27,17 @@ namespace MediaBrowser.Model.Net /// <param name="localPort">The local port to bind to.</param> /// <returns>A <see cref="IUdpSocket"/> implementation.</returns> IUdpSocket CreateUdpMulticastSocket(string ipAddress, int multicastTimeToLive, int localPort); - } + + ISocket CreateSocket(IpAddressFamily family, SocketType socketType, ProtocolType protocolType, bool dualMode); + } + + public enum SocketType + { + Stream + } + + public enum ProtocolType + { + Tcp + } } diff --git a/MediaBrowser.Model/Net/IpAddressInfo.cs b/MediaBrowser.Model/Net/IpAddressInfo.cs index b48347d1d..47ffe5118 100644 --- a/MediaBrowser.Model/Net/IpAddressInfo.cs +++ b/MediaBrowser.Model/Net/IpAddressInfo.cs @@ -4,12 +4,39 @@ namespace MediaBrowser.Model.Net { public class IpAddressInfo { + public static IpAddressInfo Any = new IpAddressInfo("0.0.0.0", IpAddressFamily.InterNetwork); + public static IpAddressInfo IPv6Any = new IpAddressInfo("00000000000000000000", IpAddressFamily.InterNetworkV6); + public static IpAddressInfo Loopback = new IpAddressInfo("127.0.0.1", IpAddressFamily.InterNetwork); + public static IpAddressInfo IPv6Loopback = new IpAddressInfo("IPv6Loopback", IpAddressFamily.InterNetworkV6); + public string Address { get; set; } - public bool IsIpv6 { get; set; } + public IpAddressFamily AddressFamily { get; set; } + + public IpAddressInfo() + { + + } + + public IpAddressInfo(string address, IpAddressFamily addressFamily) + { + Address = address; + AddressFamily = addressFamily; + } + + public bool Equals(IpAddressInfo address) + { + return string.Equals(address.Address, Address, StringComparison.OrdinalIgnoreCase); + } public override String ToString() { return Address; } } + + public enum IpAddressFamily + { + InterNetwork, + InterNetworkV6 + } } diff --git a/MediaBrowser.Model/Net/IpEndPointInfo.cs b/MediaBrowser.Model/Net/IpEndPointInfo.cs index 5fd331a16..b5cadc429 100644 --- a/MediaBrowser.Model/Net/IpEndPointInfo.cs +++ b/MediaBrowser.Model/Net/IpEndPointInfo.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; namespace MediaBrowser.Model.Net { @@ -8,11 +9,22 @@ namespace MediaBrowser.Model.Net public int Port { get; set; } + public IpEndPointInfo() + { + + } + + public IpEndPointInfo(IpAddressInfo address, int port) + { + IpAddress = address; + Port = port; + } + public override string ToString() { var ipAddresString = IpAddress == null ? string.Empty : IpAddress.ToString(); - return ipAddresString + ":" + this.Port.ToString(); + return ipAddresString + ":" + Port.ToString(CultureInfo.InvariantCulture); } } } diff --git a/MediaBrowser.Model/Services/IHasRequestFilter.cs b/MediaBrowser.Model/Services/IHasRequestFilter.cs index c5c6ccf59..2164179d5 100644 --- a/MediaBrowser.Model/Services/IHasRequestFilter.cs +++ b/MediaBrowser.Model/Services/IHasRequestFilter.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + namespace MediaBrowser.Model.Services { public interface IHasRequestFilter @@ -22,11 +17,5 @@ namespace MediaBrowser.Model.Services /// <param name="res">The http response wrapper</param> /// <param name="requestDto">The request DTO</param> void RequestFilter(IRequest req, IResponse res, object requestDto); - - /// <summary> - /// A new shallow copy of this filter is used on every request. - /// </summary> - /// <returns></returns> - IHasRequestFilter Copy(); } } diff --git a/MediaBrowser.Model/Services/IHttpResult.cs b/MediaBrowser.Model/Services/IHttpResult.cs new file mode 100644 index 000000000..36ffeb284 --- /dev/null +++ b/MediaBrowser.Model/Services/IHttpResult.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace MediaBrowser.Model.Services +{ + public interface IHttpResult : IHasHeaders + { + /// <summary> + /// The HTTP Response Status + /// </summary> + int Status { get; set; } + + /// <summary> + /// The HTTP Response Status Code + /// </summary> + HttpStatusCode StatusCode { get; set; } + + /// <summary> + /// The HTTP Status Description + /// </summary> + string StatusDescription { get; set; } + + /// <summary> + /// The HTTP Response ContentType + /// </summary> + string ContentType { get; set; } + + /// <summary> + /// Additional HTTP Cookies + /// </summary> + List<Cookie> Cookies { get; } + + /// <summary> + /// Response DTO + /// </summary> + object Response { get; set; } + + /// <summary> + /// Holds the request call context + /// </summary> + IRequest RequestContext { get; set; } + } +} diff --git a/MediaBrowser.Model/Services/IRequest.cs b/MediaBrowser.Model/Services/IRequest.cs index 45dc97b76..5dc995b06 100644 --- a/MediaBrowser.Model/Services/IRequest.cs +++ b/MediaBrowser.Model/Services/IRequest.cs @@ -60,16 +60,6 @@ namespace MediaBrowser.Model.Services QueryParamCollection QueryString { get; } QueryParamCollection FormData { get; } - /// <summary> - /// Buffer the Request InputStream so it can be re-read - /// </summary> - bool UseBufferedStream { get; set; } - - /// <summary> - /// The entire string contents of Request.InputStream - /// </summary> - /// <returns></returns> - string GetRawBody(); string RawUrl { get; } diff --git a/MediaBrowser.Model/Services/QueryParamCollection.cs b/MediaBrowser.Model/Services/QueryParamCollection.cs index 1ab3f0bfb..dfea62821 100644 --- a/MediaBrowser.Model/Services/QueryParamCollection.cs +++ b/MediaBrowser.Model/Services/QueryParamCollection.cs @@ -9,7 +9,7 @@ namespace MediaBrowser.Model.Services { public QueryParamCollection() { - + } public QueryParamCollection(IDictionary<string, string> headers) @@ -30,15 +30,30 @@ namespace MediaBrowser.Model.Services return StringComparer.OrdinalIgnoreCase; } + public string GetKey(int index) + { + return this[index].Name; + } + + public string Get(int index) + { + return this[index].Value; + } + + public virtual string[] GetValues(int index) + { + return new[] { Get(index) }; + } + /// <summary> /// Adds a new query parameter. /// </summary> - public void Add(string key, string value) + public virtual void Add(string key, string value) { Add(new NameValuePair(key, value)); } - public void Set(string key, string value) + public virtual void Set(string key, string value) { if (string.IsNullOrWhiteSpace(value)) { @@ -81,17 +96,21 @@ namespace MediaBrowser.Model.Services /// </summary> /// <returns>The number of parameters that were removed</returns> /// <exception cref="ArgumentNullException"><paramref name="name" /> is null.</exception> - public int Remove(string name) + public virtual int Remove(string name) { return RemoveAll(p => p.Name == name); } public string Get(string name) { - return GetValues(name).FirstOrDefault(); + var stringComparison = GetStringComparison(); + + return this.Where(p => string.Equals(p.Name, name, stringComparison)) + .Select(p => p.Value) + .FirstOrDefault(); } - public string[] GetValues(string name) + public virtual string[] GetValues(string name) { var stringComparison = GetStringComparison(); diff --git a/MediaBrowser.Model/Text/ITextEncoding.cs b/MediaBrowser.Model/Text/ITextEncoding.cs new file mode 100644 index 000000000..6901f1f94 --- /dev/null +++ b/MediaBrowser.Model/Text/ITextEncoding.cs @@ -0,0 +1,10 @@ +using System.Text; + +namespace MediaBrowser.Model.Text +{ + public interface ITextEncoding + { + Encoding GetASCIIEncoding(); + Encoding GetFileEncoding(string path); + } +} diff --git a/MediaBrowser.Model/TextEncoding/IEncoding.cs b/MediaBrowser.Model/TextEncoding/IEncoding.cs deleted file mode 100644 index 3d884c9d2..000000000 --- a/MediaBrowser.Model/TextEncoding/IEncoding.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Text; - -namespace MediaBrowser.Model.TextEncoding -{ - public interface IEncoding - { - byte[] GetASCIIBytes(string text); - string GetASCIIString(byte[] bytes, int startIndex, int length); - - Encoding GetFileEncoding(string path); - } -} |
