Skip to content

Commit

Permalink
Merge branch 'main' into mv/fix-16146
Browse files Browse the repository at this point in the history
  • Loading branch information
mvarblow authored May 23, 2024
2 parents e8b004a + 9a8aa1c commit e36390b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ protected virtual async Task<IContent> GetContentAsync(WorkflowExecutionContext
else
{
// If no expression was provided, see if the content item was provided as an input or as a property.
content = workflowContext.Input.GetValue<IContent>(ContentEventConstants.ContentItemInputKey)
?? workflowContext.Properties.GetValue<IContent>(ContentEventConstants.ContentItemInputKey);
content = workflowContext.Input.GetValue<ContentItem>(ContentEventConstants.ContentItemInputKey)
?? workflowContext.Properties.GetValue<ContentItem>(ContentEventConstants.ContentItemInputKey);
}

if (content != null && content.ContentItem.ContentItemId != null)
if (content?.ContentItem?.ContentItemId != null)
{
return content;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public async override Task<ActivityExecutionResult> ExecuteAsync(WorkflowExecuti
}
else
{
contentItem = workflowContext.Input.GetValue<IContent>(ContentEventConstants.ContentItemInputKey)?.ContentItem;
contentItem = workflowContext.Input.GetValue<ContentItem>(ContentEventConstants.ContentItemInputKey)?.ContentItem;
}

if (contentItem == null)
Expand Down Expand Up @@ -155,7 +155,7 @@ public async override Task<ActivityExecutionResult> ExecuteAsync(WorkflowExecuti
{
workflowContext.CorrelationId = contentItem.ContentItemId;
}

workflowContext.Properties[ContentEventConstants.ContentItemInputKey] = contentItem;
workflowContext.LastResult = contentItem;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static void AddInputObjectGraphType<TObject, TObjectType>(this IServiceCo
where TObject : class
where TObjectType : InputObjectGraphType<TObject>
{
services.AddScoped<TObjectType>();
services.AddTransient<TObjectType>();
services.AddTransient<InputObjectGraphType<TObject>, TObjectType>(s => s.GetRequiredService<TObjectType>());
services.AddTransient<IInputObjectGraphType, TObjectType>(s => s.GetRequiredService<TObjectType>());
}
Expand All @@ -30,7 +30,7 @@ public static void AddObjectGraphType<TInput, TInputType>(this IServiceCollectio
where TInput : class
where TInputType : ObjectGraphType<TInput>
{
services.AddScoped<TInputType>();
services.AddTransient<TInputType>();
services.AddTransient<ObjectGraphType<TInput>, TInputType>(s => s.GetRequiredService<TInputType>());
services.AddTransient<IObjectGraphType, TInputType>(s => s.GetRequiredService<TInputType>());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Text.Json;

namespace OrchardCore.Workflows.Helpers
{
Expand All @@ -19,12 +20,19 @@ public static TValue GetValue<TValue>(this IDictionary<string, object> dictionar
{
var value = dictionary.GetValue(key);

if (value != null)
if (value == null)
{
return (TValue)value;
return default;
}

return default;
if (value is not TValue castedValue)
{
var json = JConvert.SerializeObject(value);

return JConvert.DeserializeObject<TValue>(json);
}

return castedValue;
}

/// <summary>
Expand Down

0 comments on commit e36390b

Please sign in to comment.