Skip to content

Commit

Permalink
Upgrade MediatR to 12.0.1 fixing issue #3775 (#3790)
Browse files Browse the repository at this point in the history
  • Loading branch information
axel-bergman-stratsys authored Mar 14, 2023
1 parent 5ac53a2 commit bc8235a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/core/Elsa.Abstractions/Elsa.Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<ItemGroup>
<PackageReference Include="DistributedLock.Core" Version="1.0.4" />
<PackageReference Include="LinqKit.Core" Version="1.1.27" />
<PackageReference Include="MediatR" Version="10.0.1" />
<PackageReference Include="MediatR" Version="12.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
Expand Down
3 changes: 1 addition & 2 deletions src/core/Elsa.Core/Elsa.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
<PackageReference Include="DistributedLock.Core" Version="1.0.4" />
<PackageReference Include="DistributedLock.FileSystem" Version="1.0.1" />
<PackageReference Include="Humanizer.Core" Version="2.13.14" />
<PackageReference Include="MediatR" Version="10.0.1" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="10.0.1" />
<PackageReference Include="MediatR" Version="12.0.1" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
using Elsa.Services.Workflows;
using Elsa.Services.WorkflowStorage;
using Elsa.StartupTasks;
using MediatR;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Newtonsoft.Json;
Expand Down Expand Up @@ -254,8 +253,12 @@ private static ElsaOptionsBuilder AddWorkflowsCore(this ElsaOptionsBuilder elsaO
.AddBookmarkProvider<RunWorkflowBookmarkProvider>();

// Mediator.
services
.AddMediatR(mediatr => mediatr.AsScoped(), typeof(IActivity), typeof(LogWorkflowExecution));
services.AddMediatR(cfg =>
{
cfg.Lifetime = ServiceLifetime.Scoped;
cfg.RegisterServicesFromAssemblyContaining<IActivity>();
cfg.RegisterServicesFromAssemblyContaining<LogWorkflowExecution>();
});

// Service Bus.
services
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ public static IServiceCollection AddNotificationHandler<T, THandler>(this IServi

public static IServiceCollection AddNotificationHandlers(this IServiceCollection services, params Type[] markerTypes)
{
var assemblies = markerTypes.Select(x => x.GetTypeInfo().Assembly);
ServiceRegistrar.AddMediatRClasses(services, assemblies, new MediatRServiceConfiguration());
var assemblies = markerTypes.Select(x => x.GetTypeInfo().Assembly).ToArray();
var serviceConfiguration = new MediatRServiceConfiguration();
serviceConfiguration.RegisterServicesFromAssemblies(assemblies);
ServiceRegistrar.AddMediatRClasses(services, serviceConfiguration);
return services;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Reflection;
using Elsa.Options;
using MediatR;
using MediatR.Registration;
using Microsoft.Extensions.DependencyInjection;

namespace Elsa.Indexing.Extensions
{
Expand All @@ -13,7 +13,9 @@ public static ElsaOptionsBuilder UseIndexing(this ElsaOptionsBuilder options, Ac
var indexingOptions = new ElsaIndexingOptions(options.Services);
configure.Invoke(indexingOptions);

ServiceRegistrar.AddMediatRClasses(options.Services, new[] { Assembly.GetExecutingAssembly() }, new MediatRServiceConfiguration());
var serviceConfiguration = new MediatRServiceConfiguration();
serviceConfiguration.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
ServiceRegistrar.AddMediatRClasses(options.Services, serviceConfiguration);

return options;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="10.0.1" />
<PackageReference Include="MediatR" Version="12.0.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
var services = builder.Services;

services
.AddMediatR(typeof(DependencyInjectionExtensions))
.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(DependencyInjectionExtensions).Assembly))
.AddSingleton<IBackgroundEventPublisher, BackgroundEventPublisher>()
.AddHostedService<BackgroundEventPublisherHostedService>()
.CreateChannel<INotification>();
Expand Down

0 comments on commit bc8235a

Please sign in to comment.