Formatting
This commit is contained in:
parent
35248ef43f
commit
299b871c50
|
|
@ -65,8 +65,7 @@ namespace Elsa.Services
|
|||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
throw new CannotSetActivityPropertyValueException($@"An exception was thrown whilst setting '{activity?.GetType().Name}.{property.Name}'.
|
||||
See the inner exception for further details.", e);
|
||||
throw new CannotSetActivityPropertyValueException($@"An exception was thrown whilst setting '{activity?.GetType().Name}.{property.Name}'. See the inner exception for further details.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Services.Models;
|
||||
|
||||
|
|
@ -6,11 +7,12 @@ namespace Elsa.Services
|
|||
{
|
||||
public interface IActivityActivator
|
||||
{
|
||||
Task<IActivity> ActivateActivityAsync(ActivityExecutionContext context, Type type);
|
||||
Task<IActivity> ActivateActivityAsync(ActivityExecutionContext context, Type type, CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
public static class ActivityActivatorExtensions
|
||||
{
|
||||
public static async Task<T> ActivateActivityAsync<T>(this IActivityActivator activityActivator, ActivityExecutionContext context) where T : IActivity => (T) await activityActivator.ActivateActivityAsync(context, typeof(T));
|
||||
public static async Task<T> ActivateActivityAsync<T>(this IActivityActivator activityActivator, ActivityExecutionContext context, CancellationToken cancellationToken = default) where T : IActivity =>
|
||||
(T) await activityActivator.ActivateActivityAsync(context, typeof(T), cancellationToken);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Activities.ControlFlow;
|
||||
using Elsa.ActivityProviders;
|
||||
using Elsa.Services.Models;
|
||||
|
||||
namespace Elsa.Services
|
||||
|
|
@ -14,7 +16,7 @@ namespace Elsa.Services
|
|||
_elsaOptions = options;
|
||||
}
|
||||
|
||||
public async Task<IActivity> ActivateActivityAsync(ActivityExecutionContext context, Type type)
|
||||
public async Task<IActivity> ActivateActivityAsync(ActivityExecutionContext context, Type type, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var activity = _elsaOptions.ActivityFactory.CreateService(type, context.ServiceProvider);
|
||||
activity.Data = context.GetData();
|
||||
|
|
@ -22,7 +24,13 @@ namespace Elsa.Services
|
|||
|
||||
// TODO: Make extensible / apply open/closed.
|
||||
if(ShouldSetProperties(activity))
|
||||
{
|
||||
// TODO: Figure out how to deal with dynamically defined properties and what it means to set values to these.
|
||||
// ActivityTypes can have dynamic properties, so they need to be able to "intercept" when values are being applied.
|
||||
// Right now, we can only set these values on properties of the IActivity implementation.
|
||||
//var activityType = await _activityTypeService.GetActivityTypeAsync(activity.Type, cancellationToken);
|
||||
await context.WorkflowExecutionContext.WorkflowBlueprint.ActivityPropertyProviders.SetActivityPropertiesAsync(activity, context, context.CancellationToken);
|
||||
}
|
||||
|
||||
return activity;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue