From 479bdda002ef823f027ccaed7439882d3d851747 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Mon, 17 Jul 2023 22:11:41 +0200 Subject: [PATCH] Fix project references --- src/bundles/Elsa/Elsa.csproj | 1 - src/bundles/Elsa/Features/AppFeature.cs | 5 ++ src/common/Elsa.Mediator/Elsa.Mediator.csproj | 6 -- .../DependencyInjectionExtensions.cs | 55 +++++++++---------- .../Elsa.Common/Features/MediatorFeature.cs | 4 +- src/modules/Elsa.Email/Elsa.Email.csproj | 1 - .../Elsa.Email/Models/EmailAttachment.cs | 6 ++ .../Options/SmtpEncryptionMethod.cs | 14 +++++ 8 files changed, 55 insertions(+), 37 deletions(-) diff --git a/src/bundles/Elsa/Elsa.csproj b/src/bundles/Elsa/Elsa.csproj index 3d5aec1d6..2b3319239 100644 --- a/src/bundles/Elsa/Elsa.csproj +++ b/src/bundles/Elsa/Elsa.csproj @@ -20,7 +20,6 @@ - diff --git a/src/bundles/Elsa/Features/AppFeature.cs b/src/bundles/Elsa/Features/AppFeature.cs index 9a37a7411..0a72a3396 100644 --- a/src/bundles/Elsa/Features/AppFeature.cs +++ b/src/bundles/Elsa/Features/AppFeature.cs @@ -10,12 +10,17 @@ namespace Elsa.Features; [DependsOn(typeof(ElsaFeature))] public class AppFeature : FeatureBase { + /// public AppFeature(IModule module) : base(module) { } + /// + /// The configurator to invoke. + /// public Action? Configurator { get; set; } + /// public override void Configure() { Configurator?.Invoke(Module); diff --git a/src/common/Elsa.Mediator/Elsa.Mediator.csproj b/src/common/Elsa.Mediator/Elsa.Mediator.csproj index 2ba636fc7..2ca87f6a2 100644 --- a/src/common/Elsa.Mediator/Elsa.Mediator.csproj +++ b/src/common/Elsa.Mediator/Elsa.Mediator.csproj @@ -18,10 +18,4 @@ - - - - - - \ No newline at end of file diff --git a/src/common/Elsa.Mediator/Extensions/DependencyInjectionExtensions.cs b/src/common/Elsa.Mediator/Extensions/DependencyInjectionExtensions.cs index 15439f662..3fb5b9261 100644 --- a/src/common/Elsa.Mediator/Extensions/DependencyInjectionExtensions.cs +++ b/src/common/Elsa.Mediator/Extensions/DependencyInjectionExtensions.cs @@ -20,7 +20,7 @@ using Microsoft.Extensions.Options; namespace Microsoft.Extensions.DependencyInjection; /// -/// Adds extension methods to that enable & configure mediator specific features. +/// Adds mediator services to the . /// [PublicAPI] public static class DependencyInjectionExtensions @@ -40,25 +40,33 @@ public static class DependencyInjectionExtensions .AddSingleton() .AddSingleton() .AddSingleton() - .AddSingleton() - .AddSingleton() - .AddSingleton() - .AddSingleton() - .AddHostedService() - .AddHostedService(sp => - { - var options = sp.GetRequiredService>().Value; - return ActivatorUtilities.CreateInstance(sp, options.CommandWorkerCount); - }) - .AddHostedService(sp => - { - var options = sp.GetRequiredService>().Value; - return ActivatorUtilities.CreateInstance(sp, options.NotificationWorkerCount); - }) - .CreateChannel() - .CreateChannel() ; } + + /// + /// Adds mediator hosted services to the . + /// + /// + /// + public static IServiceCollection AddMediatorHostedServices(this IServiceCollection services) + { + return services + .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddHostedService() + .AddHostedService(sp => + { + var options = sp.GetRequiredService>().Value; + return ActivatorUtilities.CreateInstance(sp, options.CommandWorkerCount); + }) + .AddHostedService(sp => + { + var options = sp.GetRequiredService>().Value; + return ActivatorUtilities.CreateInstance(sp, options.NotificationWorkerCount); + }); + } /// /// Adds a to the and a hosted service that continuously reads from the channel and executes each received message. @@ -193,16 +201,7 @@ public static class DependencyInjectionExtensions /// Registers all handlers from the specified assembly with the service container. /// public static IServiceCollection AddCommandHandlersFrom(this IServiceCollection services, Assembly assembly) => services.AddHandlersFromInternal(assembly); - - /// - /// Registers a channel for the specified type T as well as a channel reader and writer. - /// - public static IServiceCollection CreateChannel(this IServiceCollection services) => - services - .AddSingleton(CreateChannel()) - .AddTransient(CreateChannelReader) - .AddTransient(CreateChannelWriter); - + private static IServiceCollection AddHandlersFromInternal(this IServiceCollection services) => services.AddHandlersFromInternal(typeof(TMarker)); private static IServiceCollection AddHandlersFromInternal(this IServiceCollection services, Type assemblyMarkerType) => services.AddHandlersFromInternal(assemblyMarkerType.Assembly); diff --git a/src/modules/Elsa.Common/Features/MediatorFeature.cs b/src/modules/Elsa.Common/Features/MediatorFeature.cs index 6f1df8dc4..0aaf0ddaa 100644 --- a/src/modules/Elsa.Common/Features/MediatorFeature.cs +++ b/src/modules/Elsa.Common/Features/MediatorFeature.cs @@ -17,6 +17,8 @@ public class MediatorFeature : FeatureBase /// public override void Apply() { - Services.AddMediator(); + Services + .AddMediator() + .AddMediatorHostedServices(); } } \ No newline at end of file diff --git a/src/modules/Elsa.Email/Elsa.Email.csproj b/src/modules/Elsa.Email/Elsa.Email.csproj index f5cc8df58..9148370f0 100644 --- a/src/modules/Elsa.Email/Elsa.Email.csproj +++ b/src/modules/Elsa.Email/Elsa.Email.csproj @@ -17,7 +17,6 @@ - diff --git a/src/modules/Elsa.Email/Models/EmailAttachment.cs b/src/modules/Elsa.Email/Models/EmailAttachment.cs index ee5faef77..f30ab2bc5 100644 --- a/src/modules/Elsa.Email/Models/EmailAttachment.cs +++ b/src/modules/Elsa.Email/Models/EmailAttachment.cs @@ -1,3 +1,9 @@ namespace Elsa.Email.Models; +/// +/// Represents an email attachment. +/// +/// The content of the attachment. +/// The name of the attachment. +/// The content type of the attachment. public record EmailAttachment(object Content, string? FileName, string? ContentType); \ No newline at end of file diff --git a/src/modules/Elsa.Email/Options/SmtpEncryptionMethod.cs b/src/modules/Elsa.Email/Options/SmtpEncryptionMethod.cs index 7b87fdf35..053b6af57 100644 --- a/src/modules/Elsa.Email/Options/SmtpEncryptionMethod.cs +++ b/src/modules/Elsa.Email/Options/SmtpEncryptionMethod.cs @@ -1,8 +1,22 @@ namespace Elsa.Email.Options; +/// +/// Represents the encryption method to use when connecting to an SMTP server. +/// public enum SmtpEncryptionMethod { + /// + /// No encryption. + /// None = 0, + + /// + /// SSL/TLS encryption. + /// SslTlS = 1, + + /// + /// STARTTLS encryption. + /// StartTls = 2 } \ No newline at end of file