private static CodeMemberMethod CreateInteract(string className) { var method = new CodeMemberMethod { Name = CodeConstants.SceneInteractionMethod, Attributes = MemberAttributes.Public | MemberAttributes.Static, ReturnType = CodeConstants.AsyncTask }; method.AddInteractionParams(); method.AddFlowParams(); var statements = method.Statements; statements.Add(new CodeSnippetStatement("\t\tswitch(" + CodeConstants.InteractionParameterName + "){")); statements.Add(new CodeSnippetStatement("\t\t}")); var invoke = new CodeMethodInvokeExpression( new CodeTypeReferenceExpression("await " + className), CodeConstants.ScenePrimaryMethod); invoke.AddFlowParameters(); statements.AddInteraction(className, CodeConstants.MainSceneMarker, invoke); return(method); }
public static CodeTypeDeclaration Ensure(CodeGeneratorContext context) { var type = context.CreateIntentRequestHandler(BuiltInIntent.Fallback).FirstType(); var handle = type.MethodStatements(CodeConstants.HandlerPrimaryMethod); CodeGeneration_Interaction.AddHandlerCheck(handle, context, CodeConstants.FallbackMarker); var returnStmt = handle.OfType <CodeMethodReturnStatement>().First(); if (!(returnStmt.Expression is CodeMethodInvokeExpression)) { handle.Remove(returnStmt); handle.Add(new CodeMethodReturnStatement(new CodeMethodInvokeExpression( new CodeTypeReferenceExpression("await " + BuiltInIntent.Fallback.Safe()), "Fallback" ).AddFlowParameters())); } var invoke = new CodeMethodInvokeExpression( new CodeTypeReferenceExpression("await Navigation"), CodeConstants.NavigationMethodName); invoke.AddFlowParameters(); return(type); }
public static void AddHearMarker(CodeGeneratorContext context, CodeStatementCollection statements) { while (context.CodeScope.Peek().GetType() != typeof(CodeTypeDeclaration)) { context.CodeScope.Pop(); } var type = context.CodeScope.Peek() as CodeTypeDeclaration; var count = NumberAsWord(type.Members.OfType <CodeMemberMethod>().Count(m => m.Name.StartsWith("Hear"))); var newMethod = new CodeMemberMethod { Name = "Hear_" + count, Attributes = MemberAttributes.Public | MemberAttributes.Static, ReturnType = CodeConstants.AsyncTask }; newMethod.AddFlowParams(); type.Members.Add(newMethod); context.CodeScope.Push(newMethod); var interactions = type.MethodStatements(CodeConstants.SceneInteractionMethod); var invoke = new CodeMethodInvokeExpression( new CodeTypeReferenceExpression("await " + type.Name), newMethod.Name); invoke.AddFlowParameters(); statements.Add(CodeGeneration_Navigation.EnableCandidate(context.Marker)); interactions.AddInteraction(type.Name, context.Marker, invoke, true); }