Added ability to metadata for all task types, not just a select list.
This commit is contained in:
parent
800f10f9fb
commit
e7eaed742e
@ -167,7 +167,7 @@ public class WorkflowTemplateController : ESuiteControllerBase
|
|||||||
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ProblemDetails))]
|
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ProblemDetails))]
|
||||||
[AccessKey(SecurityAccess.DeleteWorkflowTemplate)]
|
[AccessKey(SecurityAccess.DeleteWorkflowTemplate)]
|
||||||
public async Task<IActionResult> GetAllowedTaskMetadataList(
|
public async Task<IActionResult> GetAllowedTaskMetadataList(
|
||||||
[FromQuery] string taskType,
|
[FromQuery] string? taskType,
|
||||||
CancellationToken cancellationToken = default!
|
CancellationToken cancellationToken = default!
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -170,7 +170,7 @@ public class WorkflowTemplateManager : IWorkflowTemplateManager
|
|||||||
return $"{genericName}<{formattedArgs}>";
|
return $"{genericName}<{formattedArgs}>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<List<TaskMetadata>> GetAllowedTaskMetadataList(string taskType, CancellationToken cancellationToken)
|
public Task<List<TaskMetadata>> GetAllowedTaskMetadataList(string? taskType, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var taskTypeAttribute = StageExtensions.GetTaskAttributeType(taskType);
|
var taskTypeAttribute = StageExtensions.GetTaskAttributeType(taskType);
|
||||||
|
|
||||||
|
|||||||
@ -32,10 +32,10 @@ public static class StageExtensions
|
|||||||
StringComparer.OrdinalIgnoreCase
|
StringComparer.OrdinalIgnoreCase
|
||||||
);
|
);
|
||||||
|
|
||||||
public static Type GetTaskAttributeType(string taskType)
|
public static Type? GetTaskAttributeType(string taskType)
|
||||||
{
|
{
|
||||||
if (taskType == null)
|
if (string.IsNullOrWhiteSpace(taskType))
|
||||||
throw new ArgumentNullException(nameof(taskType));
|
return null;
|
||||||
|
|
||||||
var key = taskType.Trim();
|
var key = taskType.Trim();
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ public static class StageExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static readonly ConcurrentDictionary<Type, IEnumerable<Type>> AllowedTasksCache = new();
|
private static readonly ConcurrentDictionary<string, IEnumerable<Type>> AllowedTasksCache = new();
|
||||||
|
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage(
|
[System.Diagnostics.CodeAnalysis.SuppressMessage(
|
||||||
"Style", "IDE0305:Collection initialization can be simplified",
|
"Style", "IDE0305:Collection initialization can be simplified",
|
||||||
@ -61,9 +61,21 @@ public static class StageExtensions
|
|||||||
Justification = "parameter required for extension method definition")]
|
Justification = "parameter required for extension method definition")]
|
||||||
|
|
||||||
|
|
||||||
public static IEnumerable<Type> GetAllowedTaskTypes(Type attributeType)
|
public static IEnumerable<Type> GetAllowedTaskTypes(Type? attributeType)
|
||||||
{
|
{
|
||||||
return AllowedTasksCache.GetOrAdd(attributeType, _ =>
|
if (attributeType == null)
|
||||||
|
{
|
||||||
|
return AllowedTasksCache.GetOrAdd("__NULL__", _ =>
|
||||||
|
{
|
||||||
|
var generalTasks = GetAllowedTaskTypes(typeof(GeneralTaskAttribute));
|
||||||
|
var approvalTasks = GetAllowedTaskTypes(typeof(ApprovalTaskAttribute));
|
||||||
|
|
||||||
|
return generalTasks.Concat(approvalTasks).ToArray();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return AllowedTasksCache.GetOrAdd(attributeType!.FullName!, _ =>
|
||||||
{
|
{
|
||||||
return AppDomain.CurrentDomain
|
return AppDomain.CurrentDomain
|
||||||
.GetAssemblies()
|
.GetAssemblies()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user