From d8acce73cb5942944a79ca7a9b3ae113637bef07 Mon Sep 17 00:00:00 2001 From: D'Arcy Rittich Date: Sun, 10 Nov 2024 08:13:24 -0500 Subject: [PATCH] Update README.md --- README.md | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index faa7e45..39ad47f 100644 --- a/README.md +++ b/README.md @@ -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> logger = new NullLogger>(); +// Initialize the state machine with the initial state +var sm = new StateMachine(MyStates.Initial, logger); ``` ### Define the Transitions @@ -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( - currentState: MyStates.Initial, - evt: MyEvents.SomethingHappened, - nextState: MyStates.SomeState, - action: SomeMethodToExecuteAsync -)); - -sm.AddTransition(new Transition( - 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