SHARE
TWEET

Untitled

a guest Sep 17th, 2019 123 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.             Stateless.StateMachine<string, string> machine = new Stateless.StateMachine<string, string>("first room");
  2.             machine.Configure("first room")
  3.                    .Permit("Method1", "method1")
  4.                    .Permit("Method2", "method2")
  5.                    .OnActivate(() => Console.WriteLine("This is the first room"));
  6.             machine.Configure("method1")
  7.                     .Permit("Method3", "method3")
  8.                     .Permit("Method4", "metod4")
  9.                     .Permit("Back", "first room")
  10.                     .OnActivate(() => Console.WriteLine("This method is run if the user types in 'Method1'"));
  11.             machine.Configure("method2")
  12.                     .Permit("Method5", "method5")
  13.                     .Permit("Method6", "method6")
  14.                     .OnActivate(() => Console.WriteLine("This method is run if the user types in 'Method2' after the first method"));
  15.             machine.Activate();
  16.             while (true)
  17.             {
  18.                 foreach (var t in machine.PermittedTriggers)
  19.                 {
  20.                     Console.WriteLine(t);
  21.                 }
  22.                 Console.Write(">");
  23.                 string input = Console.ReadLine();
  24.                 machine.Fire(input);
  25.             }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top