diff --git a/README.md b/README.md index cca35def..9a1aecd1 100644 --- a/README.md +++ b/README.md @@ -241,7 +241,7 @@ Setting this is vital within a Microsoft Orleans Grain for example, which requir ## Building -Stateless runs on .NET 4.0+ and practically all modern .NET platforms by targeting .NET Standard 1.0 and .NET Standard2.0. Visual Studio 2017 or later is required to build the solution. +Stateless runs on .NET runtime version 4+ and practically all modern .NET platforms by targeting .NET Framework 4.6.2, .NET Standard 2.0 and .NET 8.0. Visual Studio 2017 or later is required to build the solution. ## Contributing @@ -256,5 +256,3 @@ This page is an almost-complete description of Stateless, and its explicit aim i Please use the issue tracker or the if you'd like to report problems or discuss features. (_Why the name? Stateless implements the set of rules regarding state transitions, but, at least when the delegate version of the constructor is used, doesn't maintain any internal state itself._) - -[Visual Studio 2015 and .NET Core]: https://www.microsoft.com/net/core diff --git a/src/Stateless/Stateless.csproj b/src/Stateless/Stateless.csproj index 013774f9..466706dd 100644 --- a/src/Stateless/Stateless.csproj +++ b/src/Stateless/Stateless.csproj @@ -21,6 +21,7 @@ false Apache-2.0 git + README.md @@ -45,4 +46,8 @@ + + + + diff --git a/src/Stateless/docs/README.md b/src/Stateless/docs/README.md new file mode 100644 index 00000000..52d6a74a --- /dev/null +++ b/src/Stateless/docs/README.md @@ -0,0 +1,56 @@ +# Stateless + +**Create *state machines* and lightweight *state machine-based workflows* directly in .NET code:** + +```csharp +var phoneCall = new StateMachine(State.OffHook); + +phoneCall.Configure(State.OffHook) + .Permit(Trigger.CallDialled, State.Ringing); + +phoneCall.Configure(State.Connected) + .OnEntry(t => StartCallTimer()) + .OnExit(t => StopCallTimer()) + .InternalTransition(Trigger.MuteMicrophone, t => OnMute()) + .InternalTransition(Trigger.UnmuteMicrophone, t => OnUnmute()) + .InternalTransition(_setVolumeTrigger, (volume, t) => OnSetVolume(volume)) + .Permit(Trigger.LeftMessage, State.OffHook) + .Permit(Trigger.PlacedOnHold, State.OnHold); + +// ... + +phoneCall.Fire(Trigger.CallDialled); +Assert.AreEqual(State.Ringing, phoneCall.State); +``` + +This project, as well as the example above, was inspired by +[Simple State Machine (Archived)](https://web.archive.org/web/20170814020207/http://simplestatemachine.codeplex.com/). + +## Features + +Most standard state machine constructs are supported: + + * Generic support for states and triggers of any .NET type (numbers, strings, enums, etc.) + * Hierarchical states + * Entry/exit actions for states + * Guard clauses to support conditional transitions + * Introspection + +Some useful extensions are also provided: + + * Ability to store state externally (for example, in a property tracked by an ORM) + * Parameterised triggers + * Reentrant states + * Export to DOT graph + +## Documentation + +For guidance on how to use Stateles, the +[project README file](https://github.com/dotnet-state-machine/stateless?tab=readme-ov-file#stateless----) +contains documentation and code examples. The source repository also includes a few +[example projects](https://github.com/dotnet-state-machine/stateless/tree/dev/example). + +## Contributing + +We welcome contributions to this project. Check +[CONTRIBUTING.md](https://github.com/dotnet-state-machine/stateless/blob/dev/CONTRIBUTING.md) for more info.