From 5b29451add93d424bdc3fc81eac5384f2b5ac2a0 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Sat, 3 Jun 2023 20:35:36 +0200 Subject: [PATCH] Add methods to opt out specific activities --- .../Extensions/ModuleExtensions.cs | 5 ++++ .../Features/WorkflowManagementFeature.cs | 25 ++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/modules/Elsa.Workflows.Management/Extensions/ModuleExtensions.cs b/src/modules/Elsa.Workflows.Management/Extensions/ModuleExtensions.cs index 033260e5d..ec82714a4 100644 --- a/src/modules/Elsa.Workflows.Management/Extensions/ModuleExtensions.cs +++ b/src/modules/Elsa.Workflows.Management/Extensions/ModuleExtensions.cs @@ -69,4 +69,9 @@ public static class ModuleExtensions /// Adds the specified activity type to the system. /// public static IModule AddActivity(this IModule module) where T : IActivity => module.UseWorkflowManagement(management => management.AddActivity()); + + /// + /// Removes the specified activity type from the system. + /// + public static IModule RemoveActivity(this IModule module) where T : IActivity => module.UseWorkflowManagement(management => management.RemoveActivity()); } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Management/Features/WorkflowManagementFeature.cs b/src/modules/Elsa.Workflows.Management/Features/WorkflowManagementFeature.cs index c3d2d1e1d..e825788e4 100644 --- a/src/modules/Elsa.Workflows.Management/Features/WorkflowManagementFeature.cs +++ b/src/modules/Elsa.Workflows.Management/Features/WorkflowManagementFeature.cs @@ -68,15 +68,20 @@ public class WorkflowManagementFeature : FeatureBase new(typeof(TimeSpan), PrimitivesCategory, "Represents a duration of time."), new(typeof(IDictionary), LookupsCategory, "A dictionary with string key and values."), new(typeof(IDictionary), LookupsCategory, "A dictionary with string key and object values."), - new (typeof(ExpandoObject), DynamicCategory, "A dictionary that can be typed as dynamic to access members using dot notation.") + new(typeof(ExpandoObject), DynamicCategory, "A dictionary that can be typed as dynamic to access members using dot notation.") }; /// /// Adds the specified activity type to the system. /// - public WorkflowManagementFeature AddActivity() where T : IActivity + public WorkflowManagementFeature AddActivity() where T : IActivity => AddActivity(typeof(T)); + + /// + /// Adds the specified activity type to the system. + /// + public WorkflowManagementFeature AddActivity(Type activityType) { - ActivityTypes.Add(typeof(T)); + ActivityTypes.Add(activityType); return this; } @@ -100,6 +105,20 @@ public class WorkflowManagementFeature : FeatureBase return this; } + /// + /// Removes the specified activity type from the system. + /// + public WorkflowManagementFeature RemoveActivity() where T : IActivity => RemoveActivity(typeof(T)); + + /// + /// Adds the specified activity type to the system. + /// + public WorkflowManagementFeature RemoveActivity(Type activityType) + { + ActivityTypes.Remove(activityType); + return this; + } + /// /// Adds the specified variable type to the system. ///