elsa-core/samples/aspnet/Elsa.Samples.AspNet.WorkflowServer/Activities/MyActivity.cs

47 lines
2 KiB
C#
Raw Normal View History

2023-04-28 20:41:18 +00:00
using Elsa.Extensions;
Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) * add a more generic UIHandler to customize how inputAttributes can be handle by the ui * Add IPropertyUIHandlerResolver and update PropertyUIHandlerResolver Introduced a new interface, IPropertyUIHandlerResolver, to resolve UI options for a property. Refactored PropertyUIHandlerResolver to implement this interface and removed the unnecessary partial class structure. Also, cleaned up some unnecessary usings in various files for better code organization. * Refactor variable name and description in InputDescriptor The 'uISpecifications' variable in the InputDescriptor model is renamed to 'uiSpecifications' for better readability. Additionally, the associated comment was revised to explain that the dictionary is used by the UI. * "Refactor codebase for improved organization and cleaner architecture" The codebase has been significantly refactored, moving several classes to more appropriate namespaces for improved organization and cleaner architecture. This includes shifting UI hint handlers, activities, and memory-related components, amongst others. The changes should improve code readability and maintainability, but as this is a broad refactoring effort, thorough regression testing is advised. * Add CheckList UIHint with associated handler and provider This update introduces a new UIHint called CheckList to the Elsa.Workflows.Core. This includes the necessary handler and provider classes. The handler is registered in the WorkflowsFeature.cs, and the CheckList UIHint key has been added to the InputUIHints.cs. Various associated files have been created in both the Elsa.Api.Client and Elsa.Workflows.Core project to support this new UIHint. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2023-12-26 17:56:29 +00:00
using Elsa.Workflows;
using Elsa.Workflows.Attributes;
using Elsa.Workflows.Models;
using Elsa.Workflows.UIHints;
2023-04-28 20:41:18 +00:00
2023-06-08 10:01:26 +00:00
namespace Elsa.Samples.AspNet.WorkflowServer.Activities;
2023-04-28 20:41:18 +00:00
/// <summary>
/// This activity shows how to provide default values for inputs.
/// </summary>
[Activity("Demo", "Demo", Description = "A demo activity with default settings.")]
public class MyActivity : CodeActivity
{
[Input(DefaultValue = "Hello World!")] public Input<string> Message { get; set; } = default!;
[Input(DefaultValue = true)] public Input<bool> Toggle { get; set; } = default!;
Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) * add a more generic UIHandler to customize how inputAttributes can be handle by the ui * Add IPropertyUIHandlerResolver and update PropertyUIHandlerResolver Introduced a new interface, IPropertyUIHandlerResolver, to resolve UI options for a property. Refactored PropertyUIHandlerResolver to implement this interface and removed the unnecessary partial class structure. Also, cleaned up some unnecessary usings in various files for better code organization. * Refactor variable name and description in InputDescriptor The 'uISpecifications' variable in the InputDescriptor model is renamed to 'uiSpecifications' for better readability. Additionally, the associated comment was revised to explain that the dictionary is used by the UI. * "Refactor codebase for improved organization and cleaner architecture" The codebase has been significantly refactored, moving several classes to more appropriate namespaces for improved organization and cleaner architecture. This includes shifting UI hint handlers, activities, and memory-related components, amongst others. The changes should improve code readability and maintainability, but as this is a broad refactoring effort, thorough regression testing is advised. * Add CheckList UIHint with associated handler and provider This update introduces a new UIHint called CheckList to the Elsa.Workflows.Core. This includes the necessary handler and provider classes. The handler is registered in the WorkflowsFeature.cs, and the CheckList UIHint key has been added to the InputUIHints.cs. Various associated files have been created in both the Elsa.Api.Client and Elsa.Workflows.Core project to support this new UIHint. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2023-12-26 17:56:29 +00:00
[Input(DefaultValue = "B", Options = new[] { "A", "B", "C" }, UIHint = InputUIHints.DropDown)]
2023-04-28 20:41:18 +00:00
public Input<string> SelectedOption { get; set; } = default!;
[Input(DefaultValue = new[] { "C#", "Programming" }, UIHint = InputUIHints.MultiText)]
public Input<string[]> Tags { get; set; } = default!;
[Input(DefaultValue = "B", Options = new[] { "A", "B", "C" }, UIHint = InputUIHints.RadioList)]
public Input<string> SelectedRadioOption { get; set; } = default!;
[Input(DefaultValue = new[] { "A", "C" }, Options = new[] { "A", "B", "C" }, UIHint = InputUIHints.CheckList)]
public Input<string> SelectedCheckOption { get; set; } = default!;
protected override void Execute(ActivityExecutionContext context)
{
var message = Message.Get(context);
var toggle = Toggle.Get(context);
var selectedOption = SelectedOption.Get(context);
var tags = Tags.Get(context);
var selectedRadioOption = SelectedRadioOption.Get(context);
var selectedCheckOption = SelectedCheckOption.Get(context);
Console.WriteLine(message);
Console.WriteLine("Toggle: {0}", toggle);
Console.WriteLine("Selected option: {0}", selectedOption);
Console.WriteLine("Tags: {0}", string.Join(", ", tags));
Console.WriteLine("Selected radio option: {0}", selectedRadioOption);
Console.WriteLine("Selected check option: {0}", string.Join(", ", selectedCheckOption));
}
}