From e2ecd7910dcaf308b8f2ba57f78a03f32944db09 Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Wed, 26 Jun 2019 14:07:14 -0500 Subject: [PATCH] wire up mediatR --- src/FilterLists.Agent/CaptureLists.cs | 18 ++++++++++++++++++ src/FilterLists.Agent/FilterLists.Agent.csproj | 2 ++ src/FilterLists.Agent/Program.cs | 14 +++++++++----- 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 src/FilterLists.Agent/CaptureLists.cs diff --git a/src/FilterLists.Agent/CaptureLists.cs b/src/FilterLists.Agent/CaptureLists.cs new file mode 100644 index 000000000..1180d0755 --- /dev/null +++ b/src/FilterLists.Agent/CaptureLists.cs @@ -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 + { + protected override Task Handle(Command request, CancellationToken cancellationToken) => 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 6b5dfe30e..7baeabda3 100644 --- a/src/FilterLists.Agent/FilterLists.Agent.csproj +++ b/src/FilterLists.Agent/FilterLists.Agent.csproj @@ -30,6 +30,8 @@ + + diff --git a/src/FilterLists.Agent/Program.cs b/src/FilterLists.Agent/Program.cs index 72d486580..a1faf122a 100644 --- a/src/FilterLists.Agent/Program.cs +++ b/src/FilterLists.Agent/Program.cs @@ -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(); - //service.DoSomething(); + var mediator = _serviceProvider.GetService(); + + 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().As(); - containerBuilder.Populate(new ServiceCollection()); + var serviceCollection = new ServiceCollection(); + serviceCollection.AddMediatR(typeof(Program).Assembly); + containerBuilder.Populate(serviceCollection); var container = containerBuilder.Build(); _serviceProvider = new AutofacServiceProvider(container); }