mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
wire up mediatR
This commit is contained in:
parent
345bb2f27c
commit
e2ecd7910d
3 changed files with 29 additions and 5 deletions
18
src/FilterLists.Agent/CaptureLists.cs
Normal file
18
src/FilterLists.Agent/CaptureLists.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediatR;
|
||||
|
||||
namespace FilterLists.Agent
|
||||
{
|
||||
public class CaptureLists
|
||||
{
|
||||
public class Command : IRequest
|
||||
{
|
||||
}
|
||||
|
||||
public class Handler : AsyncRequestHandler<Command>
|
||||
{
|
||||
protected override Task Handle(Command request, CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -30,6 +30,8 @@
|
|||
<PackageReference Include="Autofac" Version="4.9.2" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.4.0" />
|
||||
<PackageReference Include="LibGit2Sharp" Version="0.26.0" />
|
||||
<PackageReference Include="MediatR" Version="7.0.0" />
|
||||
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
|
||||
<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" />
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Autofac;
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace FilterLists.Agent
|
||||
|
|
@ -15,12 +17,13 @@ public static class Program
|
|||
|
||||
private static IServiceProvider _serviceProvider;
|
||||
|
||||
public static void Main()
|
||||
public static async Task Main()
|
||||
{
|
||||
RegisterServices();
|
||||
|
||||
//var service = _serviceProvider.GetService<IDemoService>();
|
||||
//service.DoSomething();
|
||||
var mediator = _serviceProvider.GetService<IMediator>();
|
||||
|
||||
await mediator.Send(new CaptureLists.Command());
|
||||
|
||||
DisposeServices();
|
||||
}
|
||||
|
|
@ -28,8 +31,9 @@ public static void Main()
|
|||
private static void RegisterServices()
|
||||
{
|
||||
var containerBuilder = new ContainerBuilder();
|
||||
//builder.RegisterType<DemoService>().As<IDemoService>();
|
||||
containerBuilder.Populate(new ServiceCollection());
|
||||
var serviceCollection = new ServiceCollection();
|
||||
serviceCollection.AddMediatR(typeof(Program).Assembly);
|
||||
containerBuilder.Populate(serviceCollection);
|
||||
var container = containerBuilder.Build();
|
||||
_serviceProvider = new AutofacServiceProvider(container);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue