DIT.Workflower
0.1.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package DIT.Workflower --version 0.1.0
NuGet\Install-Package DIT.Workflower -Version 0.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DIT.Workflower" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DIT.Workflower --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DIT.Workflower, 0.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DIT.Workflower as a Cake Addin #addin nuget:?package=DIT.Workflower&version=0.1.0 // Install DIT.Workflower as a Cake Tool #tool nuget:?package=DIT.Workflower&version=0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DIT.Workflower
Workflower is a library based on .NET Standard, To handle Finite State Machines (FSM) and workflow management.
Getting Started
Nuget
Install the latest nuget package into your ASP.NET Core application.
```sh
dotnet add package DIT.Workflower
```
You can also download support for Dependency Injection:
```sh
dotnet add package DIT.Workflower.DependencyInjection
```
Workflow Builder
using DIT.Workflower;
var builder = new WorkflowDefinitionBuilder<TState, TCommand, TContext>()
.From(TState.State_1)
.On(TCommand.GoNext)
.To(TState.State_2)
.From(TState.State_2)
.On(TCommand.GoNext)
.To(TState.State_3)
.AndOn(TCommand.GoBack)
.To(TState.State_1)
var workflow = builder.Build();
var allowedTransitions = workflow.GetAllowedTransitions(from: TState.State_2);
// allowedTransitions will be 2 transitions
// State_2 -> State_3 (GoNext)
// State_2 -> State_1 (GoBack)
Dependency Injection
In the Program.cs
, register the workflow factory, defining one or more workflow definitions.
public record PhoneCall(bool Active);
services.AddWorkflowDefinition<PhoneState, PhoneCommand, PhoneCall>(id: "constant-id", version: 1)
// Idle -> Ringing (Incoming)
.From(PhoneState.Idle)
.On(PhoneCommand.IncomingCall)
.To(PhoneState.Ringing)
// Ringing -> Connected (Accept & ctx.Active)
.From(PhoneState.Ringing)
.On(PhoneCommand.Accept)
.To(PhoneState.Connected)
.When(ctx => ctx.Active) // An instance of PhoneCall will become the ctx.
// Ringing -> Declined (Decline)
.From(PhoneState.Ringing)
.On(PhoneCommand.Decline)
.To(PhoneState.Declined)
[Route("[controller]")]
public class SampleController : JsonApiControllerBase
{
private readonly IWorkflow<PhoneState, PhoneCommand, PhoneCall> _workflow;
public SampleController(IWorkflowFactory<PhoneState, PhoneCommand, PhoneCall> factory)
{
_workflow = factory.CreateWorkflow(id: "constant-id", version: 1); // Optional version param to support versioning on workflows.
}
[HttpGet("{state}")]
[ProducesResponseType(typeof(JsonApiSingleDataResponse<InitiateRequest>), StatusCodes.Status200OK)]
public ActionResult GetRequest(PhoneState state, bool isActive)
{
var phoneCall = new PhoneCall(isActive)
var transitions = _workflow.GetAllowedTransitions(context: phoneCall, state);
return Ok(transitions)
}
}
Note: If you do not specify an id for the workflow, the default id is:
$"{typeof(TState).Name}_{typeof(TCommand).Name}_{typeof(TContext).Name}";
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on DIT.Workflower:
Package | Downloads |
---|---|
DIT.Workflower.DependencyInjection
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.