* Incremental work on WorkflowStateSerializer * Update Flow HTTP Request activity to default to Done outcome * Fix reference handling * Fix polymorphic object converter * Add comments * Add support for registering type alias during DI setup via options * Fix trigger and bookmark payload persistence * Update sample model * Add support for custom dictionary types * Split general serializer options provider into focused serializer services * Formatting * Update migrations
55 lines
2 KiB
C#
55 lines
2 KiB
C#
using System.Reflection;
|
|
using Elsa.Features.Services;
|
|
using FastEndpoints;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace Elsa.Extensions;
|
|
|
|
/// <summary>
|
|
/// Provides extensions to <see cref="IModule"/>.
|
|
/// </summary>
|
|
public static class ModuleExtensions
|
|
{
|
|
private static readonly object FastEndpointsAssembliesKey = new();
|
|
|
|
/// <summary>
|
|
/// Registers the specified assembly for FastEndpoint assembly discovery.
|
|
/// </summary>
|
|
public static IModule AddFastEndpointsAssembly(this IModule module, Assembly assembly)
|
|
{
|
|
var assemblies = module.Properties.GetOrAdd(FastEndpointsAssembliesKey, () => new HashSet<Assembly>());
|
|
assemblies.Add(assembly);
|
|
return module;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Registers the assembly for FastEndpoint assembly discovery using the specified marker type.
|
|
/// </summary>
|
|
public static IModule AddFastEndpointsAssembly<T>(this IModule module) => module.AddFastEndpointsAssembly(typeof(T));
|
|
|
|
/// <summary>
|
|
/// Registers the assembly for FastEndpoint assembly discovery using the specified marker type.
|
|
/// </summary>
|
|
public static IModule AddFastEndpointsAssembly(this IModule module, Type markerType) => module.AddFastEndpointsAssembly(markerType.Assembly);
|
|
|
|
/// <summary>
|
|
/// Returns all collected assemblies for discovery of endpoints.
|
|
/// </summary>
|
|
public static IEnumerable<Assembly> GetFastEndpointsAssembliesFromModule(this IModule module) => module.Properties.GetOrAdd(FastEndpointsAssembliesKey, () => new HashSet<Assembly>());
|
|
|
|
/// <summary>
|
|
/// Adds FastEndpoints to the service container and registers all collected assemblies for discovery of endpoints.
|
|
/// </summary>
|
|
public static IModule AddFastEndpointsFromModule(this IModule module)
|
|
{
|
|
var assemblies = module.GetFastEndpointsAssembliesFromModule().ToList();
|
|
|
|
module.Services.AddFastEndpoints(options =>
|
|
{
|
|
options.DisableAutoDiscovery = true;
|
|
options.Assemblies = assemblies;
|
|
});
|
|
|
|
return module;
|
|
}
|
|
} |