// Instantiate a new state machine in the 'off' state
var stateSwitch = new StateMachine<string, char>(start_request_holiday);
// Configure state machine with the Configure method, supplying the state to be configured as a parameter
stateSwitch.Configure(start_request_holiday).Permit(agree, project_manager_audit);
stateSwitch.Configure(project_manager_audit).Permit(agree, is_over_three);
stateSwitch.Configure(project_manager_audit).Permit(disagree, end_request);
stateSwitch.Configure(is_over_three).Permit(agree, depart_project_audit);
stateSwitch.Configure(is_over_three).Permit(disagree, end_request);
stateSwitch.Configure(depart_project_audit).Permit(agree, end_request);
Console.WriteLine("Press to toggle the switch. Any other key will exit the program.");
while (true)
{
Console.WriteLine("Switch is in state: " + stateSwitch.State);
var pressed = Console.ReadKey(true).KeyChar;
// Check if user wants to exit
if (stateSwitch.State.ToString().Contains("结束")) break;
// Use the Fire method with the trigger as payload to supply the state machine with an event.
// The state machine will react according to its configuration.
stateSwitch.Fire(pressed);
I write code like below: `const string start_request_holiday = "填写请假单"; const string project_manager_audit = "项目经理审批"; const string is_over_three = "是否大于3天"; const string depart_project_audit = "部门经理审批"; const string end_request = "流程结束"; const char agree = 'y'; const char disagree = 'n';
// Instantiate a new state machine in the 'off' state var stateSwitch = new StateMachine<string, char>(start_request_holiday);
// Configure state machine with the Configure method, supplying the state to be configured as a parameter stateSwitch.Configure(start_request_holiday).Permit(agree, project_manager_audit); stateSwitch.Configure(project_manager_audit).Permit(agree, is_over_three); stateSwitch.Configure(project_manager_audit).Permit(disagree, end_request); stateSwitch.Configure(is_over_three).Permit(agree, depart_project_audit); stateSwitch.Configure(is_over_three).Permit(disagree, end_request); stateSwitch.Configure(depart_project_audit).Permit(agree, end_request);
//node [fontname="Microsoft YaHei" shape=Mrecord] 才可以显示中文 //dot -T pdf -o phoneCall.pdf test.dot string graph = UmlDotGraph.Format(stateSwitch.GetInfo()); Console.WriteLine(graph);
Console.WriteLine("Press to toggle the switch. Any other key will exit the program.");
while (true) { Console.WriteLine("Switch is in state: " + stateSwitch.State); var pressed = Console.ReadKey(true).KeyChar;
} `
"填写请假单" -> "项目经理审批" [style="solid", label="y"]; "项目经理审批" -> "是否大于3天" [style="solid", label="y"]; "项目经理审批" -> "流程结束" [style="solid", label="n"]; "是否大于3天" -> "部门经理审批" [style="solid", label="y"]; "是否大于3天" -> "流程结束" [style="solid", label="n"]; "部门经理审批" -> "流程结束" [style="solid", label="y"]; init [label="", shape=point]; init -> "填写请假单"[style = "solid"] }
How can add it by programming.