2023-07-09 11:12:13 +00:00
|
|
|
using Elsa.Workflows.Core;
|
|
|
|
|
using Elsa.Workflows.Core.Memory;
|
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-05-11 14:53:33 +00:00
|
|
|
var memoryBlockReference = output?.MemoryBlockReference();
|
|
|
|
|
|
|
|
|
|
if (memoryBlockReference is null)
|
|
|
|
|
return default;
|
2023-01-16 18:42:45 +00:00
|
|
|
|
2023-05-11 14:53:33 +00:00
|
|
|
if(!context.ExpressionExecutionContext.TryGetBlock(memoryBlockReference, out var memoryBlock))
|
|
|
|
|
return default;
|
|
|
|
|
|
|
|
|
|
var parsedContentVariableType = (memoryBlock.Metadata as VariableBlockMetadata)?.Variable.GetType();
|
2023-01-16 18:42:45 +00:00
|
|
|
return parsedContentVariableType?.GenericTypeArguments.FirstOrDefault();
|
|
|
|
|
}
|
|
|
|
|
}
|