mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
wire up RestSharp client
This commit is contained in:
parent
e2ecd7910d
commit
3bf304aae4
3 changed files with 25 additions and 8 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediatR;
|
||||
using RestSharp;
|
||||
|
||||
namespace FilterLists.Agent
|
||||
{
|
||||
|
|
@ -12,7 +13,17 @@ public class Command : IRequest
|
|||
|
||||
public class Handler : AsyncRequestHandler<Command>
|
||||
{
|
||||
protected override Task Handle(Command request, CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
private readonly IRestClient _restClient;
|
||||
|
||||
public Handler(IRestClient restClient)
|
||||
{
|
||||
_restClient = restClient;
|
||||
}
|
||||
|
||||
protected override Task Handle(Command request, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -35,6 +35,7 @@
|
|||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.3" />
|
||||
<PackageReference Include="Microsoft.DotNet.Analyzers.Compatibility" Version="0.2.12-alpha" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
|
||||
<PackageReference Include="RestSharp" Version="106.6.9" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -4,17 +4,19 @@
|
|||
using Autofac.Extensions.DependencyInjection;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using RestSharp;
|
||||
|
||||
//TODO: get raw list urls and IDs
|
||||
//TODO: foreach list, download and persist raw list to disk with standardized name and overwriting the previous version
|
||||
//TODO: git add .
|
||||
//TODO: git commit
|
||||
//TODO: foreach list, upsert into MariaDB Rules table https://stackoverflow.com/questions/15271202/mysql-load-data-infile-with-on-duplicate-key-update
|
||||
|
||||
namespace FilterLists.Agent
|
||||
{
|
||||
public static class Program
|
||||
{
|
||||
//TODO: get raw list urls and IDs
|
||||
//TODO: foreach list, download and persist raw list to disk with standardized name and overwriting the previous version
|
||||
//TODO: git add .
|
||||
//TODO: git commit
|
||||
//TODO: foreach list, upsert into MariaDB Rules table https://stackoverflow.com/questions/15271202/mysql-load-data-infile-with-on-duplicate-key-update
|
||||
|
||||
private const string FilterListsApiBaseUrl = "https://filterlists.com/api/v1";
|
||||
private static IServiceProvider _serviceProvider;
|
||||
|
||||
public static async Task Main()
|
||||
|
|
@ -30,9 +32,12 @@ public static async Task Main()
|
|||
|
||||
private static void RegisterServices()
|
||||
{
|
||||
var containerBuilder = new ContainerBuilder();
|
||||
var serviceCollection = new ServiceCollection();
|
||||
var containerBuilder = new ContainerBuilder();
|
||||
|
||||
serviceCollection.AddMediatR(typeof(Program).Assembly);
|
||||
containerBuilder.Register<IRestClient>(c => new RestClient(FilterListsApiBaseUrl)).SingleInstance();
|
||||
|
||||
containerBuilder.Populate(serviceCollection);
|
||||
var container = containerBuilder.Build();
|
||||
_serviceProvider = new AutofacServiceProvider(container);
|
||||
|
|
|
|||
Loading…
Reference in a new issue