Skip to content

Commit

Permalink
Move HTTP OutputExtensions to a shared library for reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
sfmskywalker committed Jun 12, 2024
1 parent a7c23d3 commit 1677714
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 26 deletions.
26 changes: 0 additions & 26 deletions src/modules/Elsa.Http/Extensions/OutputExtensions.cs

This file was deleted.

17 changes: 17 additions & 0 deletions src/modules/Elsa.Workflows.Core/Extensions/OutputExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,21 @@ public static class OutputExtensions
/// Sets the output to the specified value.
/// </summary>
public static void Set<T>(this Output<T>? output, ExpressionExecutionContext context, Variable<T> value) => context.Set(output, value.Get(context));

/// <summary>
/// Gets the target type of the specified variable type, if any, linked to the output.
/// </summary>
public static Type? GetTargetType(this Output? output, ActivityExecutionContext context)
{
var memoryBlockReference = output?.MemoryBlockReference();

if (memoryBlockReference is null)
return default;

if(!context.ExpressionExecutionContext.TryGetBlock(memoryBlockReference, out var memoryBlock))
return default;

var parsedContentVariableType = (memoryBlock.Metadata as VariableBlockMetadata)?.Variable.GetType();
return parsedContentVariableType?.GenericTypeArguments.FirstOrDefault();
}
}

0 comments on commit 1677714

Please sign in to comment.