-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebStreamFactory.cs
26 lines (23 loc) · 970 Bytes
/
WebStreamFactory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace NutzCode.Libraries.Web
{
public class WebStreamFactory : IStreamFactory
{
public static WebStreamFactory Instance { get; }=new WebStreamFactory();
public async Task<WebStream> CreateStreamAsync(WebParameters pars, CancellationToken token = new CancellationToken())
{
return await WebStream.CreateStreamAsync<WebStream, WebParameters>(pars, token);
}
public async Task<string> GetUrlAsync(string url, string postData, string encoding, string uagent = "", Dictionary<string, string> headers = null)
{
return await WebStream.GetUrlAsync<WebStream, WebParameters>(CreateWebParameters(new Uri(url)), postData, encoding, uagent, headers);
}
public WebParameters CreateWebParameters(Uri uri)
{
return new WebParameters(uri);
}
}
}