return List rather than IEnum to simplify calls

This commit is contained in:
Collin M. Barrett 2019-07-02 11:06:38 -05:00
parent 9057723e8e
commit 4bf7af90ba
2 changed files with 8 additions and 14 deletions

View file

@ -31,32 +31,27 @@ protected override async Task Handle(Command request, CancellationToken cancella
var results = new List<DataFileUrlValidationResults>();
var licenseUrls = await _repo.GetAllAsync<LicenseUrls>();
var licenseUrlErrors = (await _mediator.Send(new ValidateUrls.Command(licenseUrls), cancellationToken))
.ToList();
var licenseUrlErrors = (await _mediator.Send(new ValidateUrls.Command(licenseUrls), cancellationToken));
if (licenseUrlErrors.Any())
results.Add(new DataFileUrlValidationResults("License.json", licenseUrlErrors));
var listUrls = await _repo.GetAllAsync<ListUrls>();
var listUrlErrors =
(await _mediator.Send(new ValidateUrls.Command(listUrls), cancellationToken)).ToList();
var listUrlErrors = (await _mediator.Send(new ValidateUrls.Command(listUrls), cancellationToken));
if (listUrlErrors.Any())
results.Add(new DataFileUrlValidationResults("FilterList.json", listUrlErrors));
var maintainerUrls = await _repo.GetAllAsync<MaintainerUrls>();
var maintainerUrlErrors =
(await _mediator.Send(new ValidateUrls.Command(maintainerUrls), cancellationToken)).ToList();
var maintainerUrlErrors = (await _mediator.Send(new ValidateUrls.Command(maintainerUrls), cancellationToken));
if (maintainerUrlErrors.Any())
results.Add(new DataFileUrlValidationResults("Maintainer.json", maintainerUrlErrors));
var softwareUrls = await _repo.GetAllAsync<SoftwareUrls>();
var softwareUrlErrors =
(await _mediator.Send(new ValidateUrls.Command(softwareUrls), cancellationToken)).ToList();
var softwareUrlErrors = (await _mediator.Send(new ValidateUrls.Command(softwareUrls), cancellationToken));
if (softwareUrlErrors.Any())
results.Add(new DataFileUrlValidationResults("Software.json", softwareUrlErrors));
var syntaxUrls = await _repo.GetAllAsync<SyntaxUrls>();
var syntaxUrlErrors = (await _mediator.Send(new ValidateUrls.Command(syntaxUrls), cancellationToken))
.ToList();
var syntaxUrlErrors = (await _mediator.Send(new ValidateUrls.Command(syntaxUrls), cancellationToken));
if (syntaxUrlErrors.Any())
results.Add(new DataFileUrlValidationResults("Syntax.json", syntaxUrlErrors));

View file

@ -13,7 +13,7 @@ namespace FilterLists.Agent.Features.Urls
{
public static class ValidateUrls
{
public class Command : IRequest<IEnumerable<UrlValidationResult>>
public class Command : IRequest<List<UrlValidationResult>>
{
public Command(IEnumerable<Uri> urls)
{
@ -23,7 +23,7 @@ public Command(IEnumerable<Uri> urls)
public IEnumerable<Uri> Urls { get; }
}
public class Handler : IRequestHandler<Command, IEnumerable<UrlValidationResult>>
public class Handler : IRequestHandler<Command, List<UrlValidationResult>>
{
private const int MaxDegreeOfParallelism = 5;
private readonly HttpClient _httpClient;
@ -33,8 +33,7 @@ public Handler(AgentHttpClient agentHttpClient)
_httpClient = agentHttpClient.Client;
}
public async Task<IEnumerable<UrlValidationResult>> Handle(Command request,
CancellationToken cancellationToken)
public async Task<List<UrlValidationResult>> Handle(Command request, CancellationToken cancellationToken)
{
var validator = BuildValidator(cancellationToken);
var brokenUrls = new List<UrlValidationResult>();