diff --git a/.gitignore b/.gitignore index e16bdbd..f03b9e4 100644 --- a/.gitignore +++ b/.gitignore @@ -339,4 +339,6 @@ ASALocalRun/ # BeatPulse healthcheck temp database healthchecksdb -CodeMap1.dgml \ No newline at end of file +CodeMap1.dgml + +SimpleStateMachine.png \ No newline at end of file diff --git a/Examples/Examples.csproj b/Examples/Examples.csproj index 84c2aed..afd8aea 100644 --- a/Examples/Examples.csproj +++ b/Examples/Examples.csproj @@ -6,9 +6,9 @@ - - - + + + diff --git a/README.md b/README.md index d897f73..47d57e2 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,32 @@ -[![NuGet Pre Release](https://img.shields.io/nuget/vpre/SimpleStateMachineLibrary.svg)](https://www.nuget.org/packages/SimpleStateMachineLibrary) -[![](https://img.shields.io/github/stars/SimpleStateMachine/SimpleStateMachineLibrary)](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary) -[![](https://img.shields.io/github/license/SimpleStateMachine/SimpleStateMachineLibrary)](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary) -# SimpleStateMachineLibrary + +[![NuGet Pre Release](https://img.shields.io/nuget/vpre/SimpleStateMachineLibrary.svg)](https://www.nuget.org/packages/SimpleStateMachineLibrary) [![](https://img.shields.io/github/stars/SimpleStateMachine/SimpleStateMachineLibrary)](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary) [![NuGet Downloads](https://img.shields.io/nuget/dt/SimpleStateMachineLibrary)](https://www.nuget.org/packages/SimpleStateMachineLibrary) [![](https://img.shields.io/github/license/SimpleStateMachine/SimpleStateMachineLibrary)](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary) [![](https://img.shields.io/github/languages/code-size/SimpleStateMachine/SimpleStateMachineLibrary)](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary) + [![]( https://img.shields.io/github/last-commit/SimpleStateMachine/SimpleStateMachineLibrary)](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary) [![](https://img.shields.io/badge/chat-slack-blueviolet.svg)](https://join.slack.com/t/simplestatemachine/shared_invite/zt-fnfhvvsx-fTejcpPn~PPb2ojdG_MQBg) [![](https://img.shields.io/badge/chat-telegram-blue.svg)](https://t.me/joinchat/HMLJFkv9do6aDV188rhd0w) + [![Build Status](https://dev.azure.com/GMIKE/SimpleStateMachineLibrary/_apis/build/status/SimpleStateMachine.SimpleStateMachineLibrary?branchName=master)](https://dev.azure.com/GMIKE/SimpleStateMachineLibrary/_build/latest?definitionId=2&branchName=master) + # SimpleStateMachineLibrary A C# library for realization simple state-machine on .Net -# Why SimpleStateMachine? - Create state machine in **two steps** : -1. Create scheme in [node editor](https://github.com/SimpleStateMachine/SimpleStateMachineNodeEditor) ♦️ -2. Load scheme in your project using [library](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary)📑 - - Just describe your app logic and run the state machine🚀 - -## Give a Star! :star: + + ## Give a Star! :star: If you like or are using this project please give it a star. Thanks! -## Сontent -1. [Features](#Features) -2. [Examples](#Examples) -4. [Documentation](#Documentation) -4. [License](#License) -## Features + # Why SimpleStateMachine? +Create state machine in **three** steps : + +**1.** Create scheme in [node editor🔗](https://github.com/SimpleStateMachine/SimpleStateMachineNodeEditor) and load it in your project using [this library📚](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary) +```C# +StateMachine stateMachine = new StateMachine("scheme.xml"); +``` +**2.** Describe your app logic on events⚡ + ```C# +stateMachine.GetState("State1").OnExit(Action1); +stateMachine.GetState("State2").OnEntry(Action2); +stateMachine.GetTransition("Transition1").OnInvoke(Action3); +stateMachine.OnChangeState(Action4); +``` +**3.** Run the state machine🚘 + ```C# +stateMachine.Start(); +``` +## Features💡 State machine properties: * Start state @@ -34,97 +42,23 @@ Useful extensions for work: * Export/Import to/from XML * Logging - -## Examples: - -### Structure ### -```C# - StateMachine stateMachine = new StateMachine(); - - //Add states - State state1 = stateMachine.AddState("State1"); - State state2 = stateMachine.AddState("State2"); - State state3 = stateMachine.AddState("State3"); - State state4 = stateMachine.AddState("State4"); - - //Add transitions three ways: - - //Standart way - Transition transition1 = stateMachine.AddTransition("Transition1", state1, state2); - - //From state - Transition transition2 = state2.AddTransitionFromThis("Transition2", state3); - - //To state - Transition transition3 = state4.AddTransitionToThis("Transition3", state3); - - //Add action on entry or/and exit - state1.OnExit(Action1); - state2.OnEntry(Action2); - state3.OnExit(Action3); - state4.OnExit(Action4); - - //Set start state - state1.SetAsStartState(); - - //Start work - stateMachine.Start(); -``` -### Actions Syntax ### -##### Action on entry/exit ##### -```C# - void ActionOnEtnry(State state, Dictionary parameters) - { - //you need invoke transition in entry or exit action, differently work state machine will be end - state.StateMachine.InvokeTransition("Transition1"); - } - +## Getting Started📂 +Install from Nuget: +```sh + Install-Package SimpleStateMachineLibrary ``` -##### Action on change state ##### -```C# - void ActionOnChangeState(State stateFrom, State stateTo) - { +## Documentation📄 +Documentation here: https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki - } -``` -##### Action on transition invoke ##### -```C# - void ActionOnTransitionInvoke(Transition transition, Dictionary parameters) - { + ## FAQ❔ + If you think you have found a bug, create a github [issue](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/issues). + + But if you just have questions about how to use: + +- [Slack channel](https://join.slack.com/t/simplestatemachine/shared_invite/zt-fnfhvvsx-fTejcpPn~PPb2ojdG_MQBg) +- [Telegram channel](https://t.me/joinchat/HMLJFkv9do6aDV188rhd0w) - } -``` -## Documentation -* StateMachine - * [Create](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/StateMachine#Create) - * [Import](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/StateMachine#Import) - * [Export](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/StateMachine#Export) - * [Logging](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/StateMachine#Logging) - * [OnChangeState](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/StateMachine#OnChangeState) - * [CurrentState](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/StateMachine#CurrentState) - * [PreviousState](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/StateMachine#PreviousState) - * [CurrentTransition](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/StateMachine#CurrentTransition) -* State - * [Create](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/State#Create) - * [Get](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/State#Get) - * [Exists](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/State#Exists) - * [Delete](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/State#Delete) - * [Entry](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/State#Entry) - * [Exit](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/State#Exit) -* Transition - * [Create](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/Transition#Create) - * [Get](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/Transition#Get) - * [Exists](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/Transition#Exists) - * [Delete](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/Transition#Delete) - * [Invoke](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/Transition#Invoke) - * [Parameters](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/Transition#Parameters) -* Data - * [Create](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/Data#Create) - * [Get](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/Data#Get) - * [Exists](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/Data#Exists) - * [Delete](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/Data#Delete) - * [Change](https://github.com/SimpleStateMachine/SimpleStateMachineLibrary/wiki/Data#Change) -## License +## License📑 Copyright (c) SimpleStateMachine diff --git a/SimpleStateMachineLibrary/SimpleStateMachineLibrary.csproj b/SimpleStateMachineLibrary/SimpleStateMachineLibrary.csproj index c023c1c..927afb1 100644 --- a/SimpleStateMachineLibrary/SimpleStateMachineLibrary.csproj +++ b/SimpleStateMachineLibrary/SimpleStateMachineLibrary.csproj @@ -20,7 +20,7 @@ Microsoft.Extensions.Logging.Abstractions 3.1.5 - + diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index a324721..9f2b0a0 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -7,12 +7,12 @@ - - - - - - + + + + + + diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..8c739b4 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,34 @@ +jobs: +- job: Linux + pool: + vmImage: 'ubuntu-18.04' + variables: + buildConfiguration: 'Release' + steps: + - script: cd $(Build.SourcesDirectory) && dotnet build + displayName: 'Linux Build and Tests' + - task: PublishTestResults@2 + inputs: + testRunner: VSTest + testResultsFiles: '**/*.trx' + +- job: Windows + pool: + vmImage: 'windows-2019' + variables: + buildConfiguration: 'Release' + steps: + - task: DotNetCoreInstaller@0 + inputs: + version: '3.1.302' + - script: cd $(Build.SourcesDirectory) && dotnet build + displayName: 'Windows Full Build and Tests' + - task: PublishTestResults@2 + inputs: + testRunner: VSTest + testResultsFiles: '**/*.trx' + - task: PublishCodeCoverageResults@1 + inputs: + summaryFileLocation: $(Build.SourcesDirectory)\artifacts\coverage.cobertura.xml + reportDirectory: $(Build.SourcesDirectory)\artifacts + codecoverageTool: cobertura

AltStyle によって変換されたページ (->オリジナル) /