1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-18 20:02:57 +00:00
This commit is contained in:
Jan Korf
2019-10-11 14:48:30 +02:00
parent 715fe378d5
commit 8ec902951d
33 changed files with 725 additions and 655 deletions
+30 -44
View File
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;
namespace CryptoExchange.Net.Interfaces
@@ -11,56 +12,41 @@ namespace CryptoExchange.Net.Interfaces
public interface IRequest
{
/// <summary>
/// The uri of the request
/// Accept header
/// </summary>
string Accept { set; }
/// <summary>
/// Content
/// </summary>
string? Content { get; }
/// <summary>
/// Headers
/// </summary>
HttpRequestHeaders Headers { get; }
/// <summary>
/// Method
/// </summary>
HttpMethod Method { get; set; }
/// <summary>
/// Uri
/// </summary>
Uri Uri { get; }
/// <summary>
/// The headers of the request
/// Set byte content
/// </summary>
WebHeaderCollection Headers { get; set; }
/// <param name="data"></param>
void SetContent(byte[] data);
/// <summary>
/// The method of the request
/// Set string content
/// </summary>
string Method { get; set; }
/// <param name="data"></param>
/// <param name="contentType"></param>
void SetContent(string data, string contentType);
/// <summary>
/// The timeout of the request
/// </summary>
TimeSpan Timeout { get; set; }
/// <summary>
/// Set a proxy
/// </summary>
/// <param name="host"></param>
/// <param name="port"></param>
/// <param name="login"></param>
/// <param name="password"></param>
void SetProxy(string host, int port, string login, string password);
/// <summary>
/// Content type
/// </summary>
string ContentType { get; set; }
/// <summary>
/// String content
/// </summary>
string Content { get; set; }
/// <summary>
/// Accept
/// </summary>
string Accept { get; set; }
/// <summary>
/// Content length
/// </summary>
long ContentLength { get; set; }
/// <summary>
/// Get the request stream
/// Get the response
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<Stream> GetRequestStream();
/// <summary>
/// Get the response object
/// </summary>
/// <returns></returns>
Task<IResponse> GetResponse();
Task<IResponse> GetResponse(CancellationToken cancellationToken);
}
}
@@ -1,4 +1,8 @@
namespace CryptoExchange.Net.Interfaces
using CryptoExchange.Net.Objects;
using System;
using System.Net.Http;
namespace CryptoExchange.Net.Interfaces
{
/// <summary>
/// Request factory interface
@@ -8,8 +12,16 @@
/// <summary>
/// Create a request for an uri
/// </summary>
/// <param name="method"></param>
/// <param name="uri"></param>
/// <returns></returns>
IRequest Create(string uri);
IRequest Create(HttpMethod method, string uri);
/// <summary>
/// Configure the requests created by this factory
/// </summary>
/// <param name="requestTimeout">Request timeout to use</param>
/// <param name="proxy">Proxy settings to use</param>
void Configure(TimeSpan requestTimeout, ApiProxy? proxy);
}
}
+15 -8
View File
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Threading.Tasks;
namespace CryptoExchange.Net.Interfaces
{
@@ -14,16 +14,23 @@ namespace CryptoExchange.Net.Interfaces
/// The response status code
/// </summary>
HttpStatusCode StatusCode { get; }
/// <summary>
/// Whether the status code indicates a success status
/// </summary>
bool IsSuccessStatusCode { get; }
/// <summary>
/// The response headers
/// </summary>
IEnumerable<KeyValuePair<string, IEnumerable<string>>> ResponseHeaders { get; }
/// <summary>
/// Get the response stream
/// </summary>
/// <returns></returns>
Stream GetResponseStream();
/// <summary>
/// Get the response headers
/// </summary>
/// <returns></returns>
IEnumerable<Tuple<string, string>> GetResponseHeaders();
Task<Stream> GetResponseStream();
/// <summary>
/// Close the response
/// </summary>
+3 -11
View File
@@ -34,7 +34,7 @@ namespace CryptoExchange.Net.Interfaces
/// <summary>
/// Origin
/// </summary>
string Origin { get; set; }
string? Origin { get; set; }
/// <summary>
/// Reconnecting
/// </summary>
@@ -42,11 +42,11 @@ namespace CryptoExchange.Net.Interfaces
/// <summary>
/// Handler for byte data
/// </summary>
Func<byte[], string> DataInterpreterBytes { get; set; }
Func<byte[], string>? DataInterpreterBytes { get; set; }
/// <summary>
/// Handler for string data
/// </summary>
Func<string, string> DataInterpreterString { get; set; }
Func<string, string>? DataInterpreterString { get; set; }
/// <summary>
/// Socket url
/// </summary>
@@ -64,14 +64,6 @@ namespace CryptoExchange.Net.Interfaces
/// </summary>
bool IsOpen { get; }
/// <summary>
/// Should ping connecting
/// </summary>
bool PingConnection { get; set; }
/// <summary>
/// Interval of pinging
/// </summary>
TimeSpan PingInterval { get; set; }
/// <summary>
/// Supported ssl protocols
/// </summary>
SslProtocols SSLProtocols { get; set; }