当前位置: 首页>>代码示例>>C#>>正文


C# TemplateContext.PushStatements方法代码示例

本文整理汇总了C#中TemplateContext.PushStatements方法的典型用法代码示例。如果您正苦于以下问题:C# TemplateContext.PushStatements方法的具体用法?C# TemplateContext.PushStatements怎么用?C# TemplateContext.PushStatements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TemplateContext的用法示例。


在下文中一共展示了TemplateContext.PushStatements方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteCode

        public override void WriteCode(ISequenceVisitor visitor, TemplateContext ctx)
        {
            base.WriteCode(visitor, ctx);
            ctx._("var {0}Components = System.ComponentSystem.RegisterComponent<{1}>().Components", List.VariableName, List.Item.FullName);

            var loop = new CodeIterationStatement(
                new CodeSnippetStatement(string.Format("var {0}Index = 0", Item.VariableName)),
                new CodeSnippetExpression(string.Format("{0}Index < {1}Components.Count", Item.VariableName, List.VariableName)),
                new CodeSnippetStatement(string.Format("{0}Index++", Item.VariableName))
                );

            loop.Statements._("{0} = {1}Components[{0}Index]", Item.VariableName, List.VariableName);
            ctx.PushStatements(loop.Statements);
            Next.WriteInvoke(ctx);
            ctx.PopStatements();
            ctx.CurrentStatements.Add(loop);
        }
开发者ID:InvertGames,项目名称:uFrame.ECS.Editor,代码行数:17,代码来源:LoopCollectionNode.cs

示例2: WriteHandler

        public virtual CodeMemberMethod WriteHandler(TemplateContext ctx)
        {
            var handlerMethod = ctx.CurrentDeclaration.protected_virtual_func( typeof(void), HandlerMethodName);

            if (!IsSystemEvent)
                handlerMethod.Parameters.Add(new CodeParameterDeclarationExpression(
                     EventType,
                     "data"
                 ));
            foreach (var item in this.FilterInputs)
            {
                var filter = item.FilterNode;
                if (filter == null) continue;
                handlerMethod.Parameters.Add(new CodeParameterDeclarationExpression(filter.ContextTypeName,
                    item.HandlerPropertyName.ToLower()));
            }


            if (this.Children.Any() && ctx.IsDesignerFile)
            {
                // Push the context on the code template
                var prevMethod = ctx.CurrentMethod;
                ctx.CurrentMember = handlerMethod;
                ctx.PushStatements(handlerMethod.Statements);
                // Now writing the handler method contents
                var name = "handler";
                if (true) // Used to be IsAsync
                {
                    ctx._("var {0} = new {1}()", name, HandlerMethodName);
                }
                else
                {
                    var field = ctx.CurrentDeclaration._private_(HandlerMethodName, HandlerMethodName + "Instance");
                    field.InitExpression = new CodeSnippetExpression(string.Format("new {0}()", HandlerMethodName));
                    ctx._("var {0} = {1}Instance", name, HandlerMethodName);

                }
                ctx._("{0}.System = this", name);

                WriteHandlerSetup(ctx, name, handlerMethod);
                if (DebugSystem.IsDebugMode)
                    ctx._("StartCoroutine({0}.Execute())", name);
                else
                    ctx._("{0}.Execute()", name);
                // End handler method contents
                ctx.PopStatements();
                ctx.CurrentMember = prevMethod;
            }
           
            return handlerMethod;
        }
开发者ID:InvertGames,项目名称:uFrame.ECS.Editor,代码行数:51,代码来源:HandlerNode.cs

示例3: WriteHandlerFilter

        public virtual CodeMemberMethod WriteHandlerFilter(TemplateContext ctx, CodeMemberMethod handlerMethod)
        {
            var handlerFilterMethod = ctx.CurrentDeclaration.protected_func(typeof(void), HandlerFilterMethodName);

            if (!IsSystemEvent) // No event data for system events
                handlerFilterMethod.Parameters.Add(new CodeParameterDeclarationExpression(EventType, "data"));

            ctx.PushStatements(handlerFilterMethod.Statements);


            if (!IsLoop)
            {
                var handlerInvoker = new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), HandlerMethodName);
                //

                if (!IsSystemEvent)
                    handlerInvoker.Parameters.Add(new CodeSnippetExpression("data"));

                foreach (var item in FilterInputs)
                {
                    var filter = item.FilterNode;
                    if (filter == null) continue;

                    handlerInvoker.Parameters.Add(new CodeSnippetExpression(filter.GetContextItemName(item.Name)));

                    ctx._("var {0} = {1}", filter.GetContextItemName(item.Name),
                        filter.MatchAndSelect("data." + item.MappingId));
                    ctx._if("{0} == null", filter.GetContextItemName(item.Name)).TrueStatements._("return");
                    ctx._if("!{0}.Enabled", filter.GetContextItemName(item.Name)).TrueStatements._("return");
                }
                WriteHandlerInvoker(handlerInvoker, handlerFilterMethod);
                ctx.CurrentStatements.Add(handlerInvoker);
            }
            else
            {
                var handlerInvoker = new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), HandlerMethodName);
                if (!IsSystemEvent)
                    handlerInvoker.Parameters.Add(new CodeSnippetExpression("data"));
                if (this.EntityGroup.Item != null)
                {
                    var item = this.BeginWriteLoop(ctx, this.EntityGroup.Item);
                    ctx._if("!{0}.Enabled", item).TrueStatements._("continue");
                    handlerInvoker.Parameters.Add(new CodeSnippetExpression(item));
                    ctx.CurrentStatements.Add(handlerInvoker);
                    this.EndWriteLoop(ctx);
                }
                else
                {
                    ctx.CurrentStatements.Add(handlerInvoker);
                }

            }


            ctx.PopStatements();
            return handlerFilterMethod;
        }
开发者ID:InvertGames,项目名称:uFrame.ECS.Editor,代码行数:57,代码来源:HandlerNode.cs

示例4: BeginWriteLoop

        public virtual string BeginWriteLoop(TemplateContext ctx, IMappingsConnectable connectable)
        {
            // ctx.PushStatements(ctx._if("{0} != null", ContextNode.SystemPropertyName).TrueStatements);

            ctx._("var {0}Items = {1}", connectable.Name, connectable.EnumeratorExpression);

            var iteration = new CodeIterationStatement(
                new CodeSnippetStatement(string.Format("var {0}Index = 0", connectable.Name)),
                new CodeSnippetExpression(string.Format("{0}Index < {0}Items.Count", connectable.Name)),
                new CodeSnippetStatement(string.Format("{0}Index++", connectable.Name))
                );

            ctx.CurrentStatements.Add(iteration);
            ctx.PushStatements(iteration.Statements);
            return string.Format("{0}Items[{0}Index]", connectable.Name);
        }
开发者ID:InvertGames,项目名称:uFrame.ECS.Editor,代码行数:16,代码来源:HandlerNode.cs


注:本文中的TemplateContext.PushStatements方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。