From d93aced9375ef62c8659277ef16227954807124d Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Wed, 26 Jun 2019 19:57:14 -0500 Subject: [PATCH] add stub for CaptureList --- .../{ => Entities}/ListInfo.cs | 2 +- .../ListArchiver/CaptureAllLists.cs | 4 +-- .../ListArchiver/CaptureList.cs | 35 +++++++++++++++++++ .../Events/ListReadyForCapture.cs | 14 -------- src/FilterLists.Agent/Program.cs | 2 ++ 5 files changed, 40 insertions(+), 17 deletions(-) rename src/FilterLists.Agent/{ => Entities}/ListInfo.cs (80%) create mode 100644 src/FilterLists.Agent/ListArchiver/CaptureList.cs delete mode 100644 src/FilterLists.Agent/ListArchiver/Events/ListReadyForCapture.cs diff --git a/src/FilterLists.Agent/ListInfo.cs b/src/FilterLists.Agent/Entities/ListInfo.cs similarity index 80% rename from src/FilterLists.Agent/ListInfo.cs rename to src/FilterLists.Agent/Entities/ListInfo.cs index b9ef8110a..f0c093d62 100644 --- a/src/FilterLists.Agent/ListInfo.cs +++ b/src/FilterLists.Agent/Entities/ListInfo.cs @@ -1,6 +1,6 @@ using System; -namespace FilterLists.Agent +namespace FilterLists.Agent.Entities { public class ListInfo { diff --git a/src/FilterLists.Agent/ListArchiver/CaptureAllLists.cs b/src/FilterLists.Agent/ListArchiver/CaptureAllLists.cs index b391798e3..9bb73e45e 100644 --- a/src/FilterLists.Agent/ListArchiver/CaptureAllLists.cs +++ b/src/FilterLists.Agent/ListArchiver/CaptureAllLists.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using FilterLists.Agent.Entities; using FilterLists.Agent.Infrastructure; -using FilterLists.Agent.ListArchiver.Events; using MediatR; using RestSharp; @@ -30,7 +30,7 @@ protected override async Task Handle(Command request, CancellationToken cancella var listsRequest = new RestRequest("lists"); var lists = await _apiClient.ExecuteAsync>(listsRequest); foreach (var list in lists) - await _mediator.Publish(new ListReadyForCapture(list), cancellationToken); + await _mediator.Send(new CaptureList.Command(list), cancellationToken); } } } diff --git a/src/FilterLists.Agent/ListArchiver/CaptureList.cs b/src/FilterLists.Agent/ListArchiver/CaptureList.cs new file mode 100644 index 000000000..bf3fcc236 --- /dev/null +++ b/src/FilterLists.Agent/ListArchiver/CaptureList.cs @@ -0,0 +1,35 @@ +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using FilterLists.Agent.Entities; +using MediatR; + +namespace FilterLists.Agent.ListArchiver +{ + public static class CaptureList + { + public class Command : IRequest + { + public Command(ListInfo listInfo) + { + ListInfo = listInfo; + } + + public ListInfo ListInfo { get; } + } + + public class Handler : AsyncRequestHandler + { + private readonly HttpClient _httpClient; + + public Handler(HttpClient httpClient) + { + _httpClient = httpClient; + } + + protected override async Task Handle(Command request, CancellationToken cancellationToken) + { + } + } + } +} \ No newline at end of file diff --git a/src/FilterLists.Agent/ListArchiver/Events/ListReadyForCapture.cs b/src/FilterLists.Agent/ListArchiver/Events/ListReadyForCapture.cs deleted file mode 100644 index 2b7253593..000000000 --- a/src/FilterLists.Agent/ListArchiver/Events/ListReadyForCapture.cs +++ /dev/null @@ -1,14 +0,0 @@ -using MediatR; - -namespace FilterLists.Agent.ListArchiver.Events -{ - public class ListReadyForCapture : INotification - { - public ListReadyForCapture(ListInfo listInfo) - { - ListInfo = listInfo; - } - - public ListInfo ListInfo { get; } - } -} \ No newline at end of file diff --git a/src/FilterLists.Agent/Program.cs b/src/FilterLists.Agent/Program.cs index 631129eda..2c8f68a38 100644 --- a/src/FilterLists.Agent/Program.cs +++ b/src/FilterLists.Agent/Program.cs @@ -1,4 +1,5 @@ using System; +using System.Net.Http; using System.Threading.Tasks; using Autofac; using Autofac.Extensions.DependencyInjection; @@ -36,6 +37,7 @@ private static void RegisterServices() // register Agent services serviceCollection.AddMediatR(typeof(Program).Assembly); containerBuilder.RegisterType().AsImplementedInterfaces().SingleInstance(); + containerBuilder.RegisterType().SingleInstance(); containerBuilder.Populate(serviceCollection); var container = containerBuilder.Build();