Add methods to opt out specific activities

This commit is contained in:
Sipke Schoorstra 2023-06-03 20:35:36 +02:00
parent b5439132cf
commit 5b29451add
2 changed files with 27 additions and 3 deletions

View file

@ -69,4 +69,9 @@ public static class ModuleExtensions
/// Adds the specified activity type to the system.
/// </summary>
public static IModule AddActivity<T>(this IModule module) where T : IActivity => module.UseWorkflowManagement(management => management.AddActivity<T>());
/// <summary>
/// Removes the specified activity type from the system.
/// </summary>
public static IModule RemoveActivity<T>(this IModule module) where T : IActivity => module.UseWorkflowManagement(management => management.RemoveActivity<T>());
}

View file

@ -68,15 +68,20 @@ public class WorkflowManagementFeature : FeatureBase
new(typeof(TimeSpan), PrimitivesCategory, "Represents a duration of time."),
new(typeof(IDictionary<string, string>), LookupsCategory, "A dictionary with string key and values."),
new(typeof(IDictionary<string, object>), 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.")
};
/// <summary>
/// Adds the specified activity type to the system.
/// </summary>
public WorkflowManagementFeature AddActivity<T>() where T : IActivity
public WorkflowManagementFeature AddActivity<T>() where T : IActivity => AddActivity(typeof(T));
/// <summary>
/// Adds the specified activity type to the system.
/// </summary>
public WorkflowManagementFeature AddActivity(Type activityType)
{
ActivityTypes.Add(typeof(T));
ActivityTypes.Add(activityType);
return this;
}
@ -100,6 +105,20 @@ public class WorkflowManagementFeature : FeatureBase
return this;
}
/// <summary>
/// Removes the specified activity type from the system.
/// </summary>
public WorkflowManagementFeature RemoveActivity<T>() where T : IActivity => RemoveActivity(typeof(T));
/// <summary>
/// Adds the specified activity type to the system.
/// </summary>
public WorkflowManagementFeature RemoveActivity(Type activityType)
{
ActivityTypes.Remove(activityType);
return this;
}
/// <summary>
/// Adds the specified variable type to the system.
/// </summary>