Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
drittich authored Nov 10, 2024
1 parent 0da823e commit d8acce7
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,14 @@ public class MyDto
### Initialize the State Machine

```csharp
// Add transitions to the state machine
sm.AddTransition(MyStates.Initial, MyEvents.SomethingHappened, MyStates.SomeState, SomeMethodToExecuteAsync);
sm.AddTransition(MyStates.SomeState, MyEvents.SomethingElseHappened, MyStates.Complete, SomeOtherMethodToExecuteAsync);
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;

// Create a logger (use NullLogger if you don't need logging)
ILogger<StateMachine<MyStates, MyEvents, MyDto>> logger = new NullLogger<StateMachine<MyStates, MyEvents, MyDto>>();

// Initialize the state machine with the initial state
var sm = new StateMachine<MyStates, MyEvents, MyDto>(MyStates.Initial, logger);
```

### Define the Transitions
Expand All @@ -75,19 +79,8 @@ With the simplified AddTransition method, you can now add transitions directly w

```csharp
// Add transitions to the state machine
sm.AddTransition(new Transition<MyStates, MyEvents, MyDto>(
currentState: MyStates.Initial,
evt: MyEvents.SomethingHappened,
nextState: MyStates.SomeState,
action: SomeMethodToExecuteAsync
));

sm.AddTransition(new Transition<MyStates, MyEvents, MyDto>(
currentState: MyStates.SomeState,
evt: MyEvents.SomethingElseHappened,
nextState: MyStates.Complete,
action: SomeOtherMethodToExecuteAsync
));
sm.AddTransition(MyStates.Initial, MyEvents.SomethingHappened, MyStates.SomeState, SomeMethodToExecuteAsync);
sm.AddTransition(MyStates.SomeState, MyEvents.SomethingElseHappened, MyStates.Complete, SomeOtherMethodToExecuteAsync);
```

### Define the Action Methods
Expand Down

0 comments on commit d8acce7

Please sign in to comment.