mirror of
https://github.com/Jackett/Jackett
synced 2025-03-01 01:15:47 +00:00
* Use platform detection that works on mono 4.6+ * Move to use package reference for restoring nuget packages. * DateTimeRoutines does not have Nuget packages that support .NET Standard (and therefore .NET Core). We will have to include them for now until we can get rid of this dependency. * Start spliting some interfaces into their own files - this will help by allowing us to split them out in the future into a seperate project so the actual implementations can stay within their respective architectures when required * Move out common libraries * Few more tidy up tasks to get things working with .NET Standard * Restructure the solution layout * Encoding work to reduce rework later on platforms without Windows codepages (or require compliance with RFC1345) * Move folder structure around to have more natural layout of the solutions * DI server configuration to get rid of "temporary" hack and dependency circle for serverservice * Make all encoding consistent to match the expected encoding casing for earlier versions of mono.
52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
using Jackett.Services;
|
|
using Jackett.Utils.Clients;
|
|
using NLog;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Jackett.Services.Interfaces;
|
|
using Jackett.Models.Config;
|
|
|
|
namespace Jackett.Test
|
|
{
|
|
public class TestWebClient : WebClient
|
|
{
|
|
private Dictionary<WebRequest, Func<WebRequest, WebClientByteResult>> byteCallbacks = new Dictionary<WebRequest, Func<WebRequest, WebClientByteResult>>();
|
|
private Dictionary<WebRequest, Func<WebRequest, WebClientStringResult>> stringCallbacks = new Dictionary<WebRequest, Func<WebRequest, WebClientStringResult>>();
|
|
|
|
public TestWebClient(IProcessService p, Logger l, IConfigurationService c, ServerConfig sc)
|
|
: base(p: p,
|
|
l: l,
|
|
c: c,
|
|
sc: sc)
|
|
{
|
|
}
|
|
|
|
public void RegisterByteCall(WebRequest req, Func<WebRequest, WebClientByteResult> f)
|
|
{
|
|
byteCallbacks.Add(req, f);
|
|
}
|
|
|
|
public void RegisterStringCall(WebRequest req, Func<WebRequest, WebClientStringResult> f)
|
|
{
|
|
stringCallbacks.Add(req, f);
|
|
}
|
|
|
|
override public Task<WebClientByteResult> GetBytes(WebRequest request)
|
|
{
|
|
return Task.FromResult< WebClientByteResult>(byteCallbacks.Where(r => r.Key.Equals(request)).First().Value.Invoke(request));
|
|
}
|
|
|
|
override public Task<WebClientStringResult> GetString(WebRequest request)
|
|
{
|
|
return Task.FromResult<WebClientStringResult>(stringCallbacks.Where(r => r.Key.Equals(request)).First().Value.Invoke(request));
|
|
}
|
|
|
|
override public void Init()
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|