mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-10-08 20:31:09 +00:00
Added unit tests, added solution, added travis build
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using CryptoExchange.Net.Interfaces;
|
||||
|
||||
namespace CryptoExchange.Net.Requests
|
||||
{
|
||||
public class Request : IRequest
|
||||
{
|
||||
private readonly WebRequest request;
|
||||
|
||||
public Request(WebRequest request)
|
||||
{
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public WebHeaderCollection Headers
|
||||
{
|
||||
get => request.Headers;
|
||||
set => request.Headers = value;
|
||||
}
|
||||
public string ContentType
|
||||
{
|
||||
get => request.ContentType;
|
||||
set => request.ContentType = value;
|
||||
}
|
||||
|
||||
public string Accept
|
||||
{
|
||||
get => ((HttpWebRequest)request).Accept;
|
||||
set => ((HttpWebRequest)request).Accept = value;
|
||||
}
|
||||
|
||||
public long ContentLength
|
||||
{
|
||||
get => ((HttpWebRequest)request).ContentLength;
|
||||
set => ((HttpWebRequest)request).ContentLength = value;
|
||||
}
|
||||
|
||||
public string Method
|
||||
{
|
||||
get => request.Method;
|
||||
set => request.Method = value;
|
||||
}
|
||||
|
||||
public Uri Uri => request.RequestUri;
|
||||
|
||||
public void SetProxy(string host, int port)
|
||||
{
|
||||
request.Proxy = new WebProxy(host, port);
|
||||
}
|
||||
|
||||
public async Task<Stream> GetRequestStream()
|
||||
{
|
||||
return await request.GetRequestStreamAsync();
|
||||
}
|
||||
|
||||
public async Task<IResponse> GetResponse()
|
||||
{
|
||||
return new Response(await request.GetResponseAsync().ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System.Net;
|
||||
using CryptoExchange.Net.Interfaces;
|
||||
|
||||
namespace CryptoExchange.Net.Requests
|
||||
{
|
||||
public class RequestFactory : IRequestFactory
|
||||
{
|
||||
public IRequest Create(string uri)
|
||||
{
|
||||
return new Request(WebRequest.Create(uri));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using CryptoExchange.Net.Interfaces;
|
||||
|
||||
namespace CryptoExchange.Net.Requests
|
||||
{
|
||||
public class Response : IResponse
|
||||
{
|
||||
private readonly WebResponse response;
|
||||
|
||||
public Response(WebResponse response)
|
||||
{
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public Stream GetResponseStream()
|
||||
{
|
||||
return response.GetResponseStream();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user