mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
add stub for CaptureList
This commit is contained in:
parent
1edc44af2f
commit
d93aced937
5 changed files with 40 additions and 17 deletions
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
|
||||
namespace FilterLists.Agent
|
||||
namespace FilterLists.Agent.Entities
|
||||
{
|
||||
public class ListInfo
|
||||
{
|
||||
|
|
@ -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<IEnumerable<ListInfo>>(listsRequest);
|
||||
foreach (var list in lists)
|
||||
await _mediator.Publish(new ListReadyForCapture(list), cancellationToken);
|
||||
await _mediator.Send(new CaptureList.Command(list), cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
35
src/FilterLists.Agent/ListArchiver/CaptureList.cs
Normal file
35
src/FilterLists.Agent/ListArchiver/CaptureList.cs
Normal file
|
|
@ -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<Command>
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
|
||||
public Handler(HttpClient httpClient)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
}
|
||||
|
||||
protected override async Task Handle(Command request, CancellationToken cancellationToken)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
|
@ -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<FilterListsApiClient>().AsImplementedInterfaces().SingleInstance();
|
||||
containerBuilder.RegisterType<HttpClient>().SingleInstance();
|
||||
|
||||
containerBuilder.Populate(serviceCollection);
|
||||
var container = containerBuilder.Build();
|
||||
|
|
|
|||
Loading…
Reference in a new issue