-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Serialize/deserialize enums to/from strings
- Loading branch information
Showing
6 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
using ConductorSharp.Engine.Model; | ||
using ConductorSharp.Engine.Util; | ||
using MediatR; | ||
using Newtonsoft.Json; | ||
|
||
namespace ConductorSharp.Definitions.Generated | ||
{ | ||
|
@@ -59,4 +60,37 @@ public partial class CustomerGetV1Output | |
/// | ||
[OriginalName("CUSTOMER_get")] | ||
public partial class CustomerGetV1 : SimpleTaskModel<CustomerGetV1Input, CustomerGetV1Output> { } | ||
|
||
public partial class EnumTaskInput : IRequest<EnumTaskOutput> | ||
{ | ||
/// <originalName> | ||
/// status | ||
/// </originalName> | ||
[JsonProperty("status")] | ||
public object Status { get; set; } | ||
} | ||
|
||
public partial class EnumTaskOutput | ||
{ | ||
/// <originalName> | ||
/// status | ||
/// </originalName> | ||
[JsonProperty("status")] | ||
public object Status { get; set; } | ||
} | ||
|
||
/// <originalName> | ||
/// ENUM_task | ||
/// </originalName> | ||
/// <ownerEmail> | ||
/// [email protected] | ||
/// </ownerEmail> | ||
/// <node> | ||
/// | ||
/// </node> | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
[OriginalName("ENUM_task")] | ||
public partial class EnumTask : SimpleTaskModel<EnumTaskInput, EnumTaskOutput> { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
examples/ConductorSharp.Definitions/Workflows/EnumWorkflow.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using ConductorSharp.Client.Generated; | ||
using ConductorSharp.Definitions.Generated; | ||
using ConductorSharp.Engine.Builders; | ||
using ConductorSharp.Engine.Builders.Metadata; | ||
|
||
namespace ConductorSharp.Definitions.Workflows | ||
{ | ||
public class EnumWorkflowInput : WorkflowInput<EnumWorkflowOutput> { } | ||
|
||
public class EnumWorkflowOutput : WorkflowOutput { } | ||
|
||
[OriginalName("ENUM_workflow")] | ||
public class EnumWorkflow : Workflow<EnumWorkflow, EnumWorkflowInput, EnumWorkflowOutput> | ||
{ | ||
public EnumWorkflow(WorkflowDefinitionBuilder<EnumWorkflow, EnumWorkflowInput, EnumWorkflowOutput> builder) | ||
: base(builder) { } | ||
|
||
public EnumTask EnumTask1 { get; set; } | ||
public EnumTask EnumTask2 { get; set; } | ||
|
||
public override void BuildDefinition() | ||
{ | ||
_builder.AddTask(wf => wf.EnumTask1, wf => new() { Status = 1 }); | ||
|
||
_builder.AddTask(wf => wf.EnumTask2, wf => new() { Status = wf.EnumTask1.Output.Status }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using ConductorSharp.Client.Generated; | ||
using ConductorSharp.Engine; | ||
using ConductorSharp.Engine.Builders.Metadata; | ||
using MediatR; | ||
|
||
namespace ConductorSharp.NoApi.Handlers | ||
{ | ||
public class EnumTaskInput : IRequest<EnumTaskOutput> | ||
{ | ||
public WorkflowStatus Status { get; set; } | ||
} | ||
|
||
public class EnumTaskOutput | ||
{ | ||
public WorkflowStatus Status { get; set; } | ||
} | ||
|
||
[OriginalName("ENUM_task")] | ||
public class EnumTaskHandler : TaskRequestHandler<EnumTaskInput, EnumTaskOutput> | ||
{ | ||
public override Task<EnumTaskOutput> Handle(EnumTaskInput request, CancellationToken cancellationToken) | ||
{ | ||
Console.WriteLine(request.Status); | ||
return System.Threading.Tasks.Task.FromResult(new EnumTaskOutput() { Status = request.Status }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters