Restore IActivityFactory and its implementation for backwards compatibility with 3.5.x, and register it in the DI container

This commit is contained in:
Sipke Schoorstra 2025-12-02 19:49:31 +01:00
parent 471ae03266
commit 099a3204fd
No known key found for this signature in database
GPG key ID: 5C10502B28A4268F
3 changed files with 23 additions and 0 deletions

View file

@ -0,0 +1,9 @@
using Elsa.Workflows.Models;
namespace Elsa.Workflows;
[Obsolete("Use the CreateActivity method on the ActivityConstructorContext context itself")]
public interface IActivityFactory
{
IActivity Create(Type type, ActivityConstructorContext context);
}

View file

@ -182,6 +182,7 @@ public class WorkflowsFeature : FeatureBase
.AddScoped<IActivityRegistryLookupService, ActivityRegistryLookupService>()
.AddSingleton<IPropertyDefaultValueResolver, PropertyDefaultValueResolver>()
.AddSingleton<IPropertyUIHandlerResolver, PropertyUIHandlerResolver>()
.AddSingleton<IActivityFactory, ActivityFactory>()
.AddTransient<WorkflowBuilder>()
.AddScoped(typeof(Func<IWorkflowBuilder>), sp => () => sp.GetRequiredService<WorkflowBuilder>())
.AddScoped<IWorkflowBuilderFactory, WorkflowBuilderFactory>()

View file

@ -0,0 +1,13 @@
using Elsa.Workflows.Models;
namespace Elsa.Workflows;
/// <inheritdoc />
public class ActivityFactory : IActivityFactory
{
/// <inheritdoc />
public IActivity Create(Type type, ActivityConstructorContext context)
{
return context.CreateActivity(type);
}
}