2023-01-16 18:42:45 +00:00
|
|
|
using Elsa.Workflows.Core.Models;
|
|
|
|
|
|
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
|
|
|
namespace Elsa.Extensions;
|
|
|
|
|
|
|
|
|
|
internal static class OutputExtensions
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the target type of the specified variable type.
|
|
|
|
|
/// </summary>
|
2023-01-17 11:22:44 +00:00
|
|
|
public static Type? GetTargetType(this Output? output, ActivityExecutionContext context)
|
2023-01-16 18:42:45 +00:00
|
|
|
{
|
2023-01-17 11:22:44 +00:00
|
|
|
var memoryBlock = output?.MemoryBlockReference() is Variable variable
|
2023-01-16 18:42:45 +00:00
|
|
|
? context.WorkflowExecutionContext.MemoryRegister.TryGetBlock(variable.Id, out var block)
|
|
|
|
|
? block
|
|
|
|
|
: default
|
|
|
|
|
: default;
|
|
|
|
|
|
|
|
|
|
var parsedContentVariableType = (memoryBlock?.Metadata as VariableBlockMetadata)?.Variable.GetType();
|
|
|
|
|
return parsedContentVariableType?.GenericTypeArguments.FirstOrDefault();
|
|
|
|
|
}
|
|
|
|
|
}
|