Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ddf25b9

Browse files
committed
examples
1 parent 3b2a986 commit ddf25b9

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

Examples/Example.ConsoleApp/ReadmeExample2.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,19 @@ public static void Run()
1414
.OnEnter(x => Console.WriteLine($"State change to {x.State} from {x.PrevState}"))
1515

1616
.State(States.S1)
17-
.On<Event1, string>().Execute(x => { /* some operations */ return $"{x.Data.SomeProp} results"; })
17+
.On<Event1, string>().Execute(x => $"{x.Data.SomeProp} results")
1818
.On<Event2>().JumpTo(States.S2)
1919

2020
.State(States.S2)
21-
.On<Event3>().Enable(x => /* some conditions */ true).JumpTo(States.S3)
21+
.On<Event3>().JumpTo(States.S3)
2222

2323
.State(States.S3)
2424
.OnEnter(x => Console.WriteLine($"Enter to final state"))
2525

2626
.Build();
2727

2828

29-
Console.WriteLine(fsm.Trigger(new Event1
30-
{
31-
SomeProp = "example"
32-
}));
29+
Console.WriteLine(fsm.Trigger(new Event1 { SomeProp = 123 }));
3330

3431
fsm.Trigger(new Event2());
3532

@@ -41,7 +38,7 @@ public static void Run()
4138

4239
class Event1 : IFsmEvent<string>
4340
{
44-
public string? SomeProp { get; set; }
41+
public int SomeProp { get; set; }
4542
}
4643

4744
class Event2 : IFsmEvent<object>;

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fsm.Trigger(Event.E3);
3838
```C#
3939
class Event1 : IFsmEvent<string>
4040
{
41-
public string? SomeProp { get; set; }
41+
public int SomeProp { get; set; }
4242
}
4343

4444
class Event2 : IFsmEvent<object>;
@@ -48,10 +48,10 @@ class Event3 : IFsmEvent<object>;
4848
var fsm = new FsmBuilder<States, Type>(States.S1)
4949
.OnEnter(x => Console.WriteLine($"State change to {x.State} from {x.PrevState}"))
5050
.State(States.S1)
51-
.On<Event1, string>().Execute(x => { /* some operations */ return $"{x.Data.SomeProp} results"; })
51+
.On<Event1, string>().Execute(x => $"{x.Data.SomeProp} results")
5252
.On<Event2>().JumpTo(States.S2)
5353
.State(States.S2)
54-
.On<Event3>().Enable(x => /* some conditions */ true).JumpTo(States.S3)
54+
.On<Event3>().JumpTo(States.S3)
5555
.State(States.S3)
5656
.OnEnter(x => Console.WriteLine($"Enter to final state"))
5757
.Build();
@@ -67,7 +67,7 @@ fsm.Trigger(new Event3());
6767

6868

6969
// Console output:
70-
// example results
70+
// 123 results
7171
// State change to S2 from S1
7272
// State change to S3 from S2
7373
// Enter to final state

0 commit comments

Comments
 (0)