From 3bf304aae4b8696f696ae90d127bab412b6cc61f Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Wed, 26 Jun 2019 14:47:50 -0500 Subject: [PATCH] wire up RestSharp client --- src/FilterLists.Agent/CaptureLists.cs | 13 ++++++++++++- .../FilterLists.Agent.csproj | 1 + src/FilterLists.Agent/Program.cs | 19 ++++++++++++------- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/FilterLists.Agent/CaptureLists.cs b/src/FilterLists.Agent/CaptureLists.cs index 1180d0755..9f38c1f09 100644 --- a/src/FilterLists.Agent/CaptureLists.cs +++ b/src/FilterLists.Agent/CaptureLists.cs @@ -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 { - 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; + } } } } \ No newline at end of file diff --git a/src/FilterLists.Agent/FilterLists.Agent.csproj b/src/FilterLists.Agent/FilterLists.Agent.csproj index 7baeabda3..08a11096c 100644 --- a/src/FilterLists.Agent/FilterLists.Agent.csproj +++ b/src/FilterLists.Agent/FilterLists.Agent.csproj @@ -35,6 +35,7 @@ + \ No newline at end of file diff --git a/src/FilterLists.Agent/Program.cs b/src/FilterLists.Agent/Program.cs index a1faf122a..646f6da85 100644 --- a/src/FilterLists.Agent/Program.cs +++ b/src/FilterLists.Agent/Program.cs @@ -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(c => new RestClient(FilterListsApiBaseUrl)).SingleInstance(); + containerBuilder.Populate(serviceCollection); var container = containerBuilder.Build(); _serviceProvider = new AutofacServiceProvider(container);