Beispiel #1
0
 private static StateMethod MapMethod(MethodDeclarationSyntax method)
 {
     return(method.Identifier.ToFullString() switch
     {
         var assign when assign.StartsWith("AssignTo_")
         => new StateMethod
         {
             Type = "Assign", Expression = method.ExtractExpression(), State = assign.Substring("AssignTo_".Length)
         },
         var transition when transition.StartsWith("EvaluateStateTransition_")
         => new StateMethod
         {
             Type = "Transition", Expression = method.ExtractExpression(), State = transition.Substring("EvaluateStateTransition_".Length)
         },
         var stateIn when stateIn.StartsWith("On") && stateIn.EndsWith("In")
         => new StateMethod
         {
             Type = stateIn, Expression = method.ExtractExpression(), State = stateIn.Substring("On".Length, stateIn.Length - "In".Length - 2)
         },
         var stateOut when stateOut.StartsWith("On") && stateOut.EndsWith("Out")
         => new StateMethod
         {
             Type = stateOut, Expression = method.ExtractExpression(), State = stateOut.Substring("On".Length, stateOut.Length - "Out".Length - 2)
         },
         _ => throw new NotSupportedException()
     });