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


C# TemplateContext._方法代码示例

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


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

示例1: WriteCode

        public virtual void WriteCode(TemplateContext ctx, ActionNode node)
        {
            var varStatement = ctx.CurrentDeclaration._private_(node.Meta.FullName, node.VarName);
            varStatement.InitExpression = new CodeObjectCreateExpression(node.Meta.FullName);

            foreach (var item in node.GraphItems.OfType<IActionIn>())
            {
                var contextVariable = item.Item;
                if (contextVariable == null)
                    continue;
                ctx._("{0}.{1} = {2}", varStatement.Name, item.Name, item.VariableName);
            }


            ctx._("{0}.System = System", varStatement.Name);


            foreach (var item in node.GraphItems.OfType<ActionBranch>())
            {
                var branchOutput = item.OutputTo<SequenceItemNode>();
                if (branchOutput == null) continue;
                if (DebugSystem.IsDebugMode)
                    ctx._("{0}.{1} = ()=> {{ System.StartCoroutine({2}()); }}", varStatement.Name, item.Name, item.VariableName);
                else
                    ctx._("{0}.{1} = {2}", varStatement.Name, item.Name, item.VariableName);
            }

            ctx._("{0}.Execute()", varStatement.Name);

            node.WriteActionOutputs(ctx);
        }
开发者ID:InvertGames,项目名称:uFrame.ECS.Editor,代码行数:31,代码来源:ActionMetaInfo.cs

示例2: WriteEventSubscription

 public override void WriteEventSubscription(TemplateContext ctx, CodeMemberMethod filterMethod, CodeMemberMethod handlerMethod)
 {
     if (EntityGroup.Item != null)
     {
         ctx._("{0}Manager.CreatedObservable.Subscribe({1}).DisposeWith(this)", EntityGroup.Item,
             filterMethod.Name);
     }
 }
开发者ID:InvertGames,项目名称:uFrame.ECS.Editor,代码行数:8,代码来源:ComponentCreatedNode.cs

示例3: WriteCode

        public override void WriteCode(ISequenceVisitor visitor, TemplateContext ctx)
        {
            
            var ctxVariable = VariableInputSlot.Item;
            if (ctxVariable == null) return;

            ctx._("{0} = ({1}){2}", ctxVariable.VariableName, ctxVariable.VariableType.FullName,
                ValueInputSlot.VariableName);
        }
开发者ID:InvertGames,项目名称:uFrame.ECS.Editor,代码行数:9,代码来源:SetVariableNode.cs

示例4: WriteEventSubscription

        public override void WriteEventSubscription(TemplateContext ctx, CodeMemberMethod filterMethod, CodeMemberMethod handlerMethod)
        {
            //base.WriteEventSubscription(ctx, filterMethod, handlerMethod);
            var relatedTypeProperty = SourceProperty.Source.MemberType as CollectionTypeInfo;

            filterMethod.Parameters.Add(new CodeParameterDeclarationExpression(relatedTypeProperty.ChildItem.MemberType.FullName, "item"));
            handlerMethod.Parameters.Add(new CodeParameterDeclarationExpression(relatedTypeProperty.ChildItem.MemberType.FullName, "item"));

            ctx._("this.CollectionItemRemoved<{0},{1}>(Group=>{2}, {3})",
                EventType, relatedTypeProperty.ChildItem.MemberType.FullName, SourceProperty.Name, filterMethod.Name);
     
        }
开发者ID:InvertGames,项目名称:uFrame.ECS.Editor,代码行数:12,代码来源:CollectionItemRemovedNode.cs

示例5: WriteEventSubscription

        public override void WriteEventSubscription(TemplateContext ctx, CodeMemberMethod filterMethod, CodeMemberMethod handlerMethod)
        {
            //base.WriteEventSubscription(ctx, filterMethod, handlerMethod);
            var relatedTypeProperty = SourceProperty.Source;
	        filterMethod.Parameters.Add(new CodeParameterDeclarationExpression(string.Format("PropertyChangedEvent<{0}>",relatedTypeProperty.MemberType.FullName), "value"));
            handlerMethod.Parameters.Add(new CodeParameterDeclarationExpression(string.Format("PropertyChangedEvent<{0}>", relatedTypeProperty.MemberType.FullName), "value"));
            if (Immediate)
            {
                ctx._("this.PropertyChangedEvent<{0},{1}>(Group=>{2}Observable, {3}, Group=>{2}, {4})", 
                    EventType, relatedTypeProperty.MemberType.FullName, SourceProperty.Name, filterMethod.Name, OnlyWhenChanged ? "true" : "false");
            }
            else
            {
                ctx._("this.PropertyChangedEvent<{0},{1}>(Group=>{2}Observable, {3}, null, {4})", EventType, relatedTypeProperty.MemberType.FullName, SourceProperty.Name, filterMethod.Name, OnlyWhenChanged ? "true" : "false");
            }
            
        }
开发者ID:InvertGames,项目名称:uFrame.ECS.Editor,代码行数:17,代码来源:PropertyChangedNode.cs

示例6: WriteCode

        public override void WriteCode(ISequenceVisitor visitor, TemplateContext ctx)
        {
            base.WriteCode(visitor, ctx);

            ctx._("{0} = {1}[UnityEngine.Random.Range(0, {1}.Count)]", Result.VariableName, List.VariableName);
        }
开发者ID:InvertGames,项目名称:uFrame.ECS.Editor,代码行数:6,代码来源:LoopCollectionNode.cs

示例7: WriteHandlerSetup

 protected override void WriteHandlerSetup(TemplateContext ctx, string name, CodeMemberMethod handlerMethod)
 {
     base.WriteHandlerSetup(ctx, name, handlerMethod);
     ctx._("{0}.OldValue = value.PreviousValue", name);
     ctx._("{0}.NewValue = value.CurrentValue", name);
 }
开发者ID:InvertGames,项目名称:uFrame.ECS.Editor,代码行数:6,代码来源:PropertyChangedNode.cs

示例8: WriteHandlerSetup

        protected virtual void WriteHandlerSetup(TemplateContext ctx, string name, CodeMemberMethod handlerMethod)
        {
            if (!IsSystemEvent)
            {
                ctx._("{0}.Event = data", name);
            }
            foreach (var item in this.FilterInputs)
            {
                var filter = item.FilterNode;
                if (filter == null) continue;
                ctx._("{0}.{1} = {2}", name, item.HandlerPropertyName, item.HandlerPropertyName.ToLower());

            }
        }
开发者ID:InvertGames,项目名称:uFrame.ECS.Editor,代码行数:14,代码来源:HandlerNode.cs

示例9: WriteHandlerSetup

 protected override void WriteHandlerSetup(TemplateContext ctx, string name, CodeMemberMethod handlerMethod)
 {
     base.WriteHandlerSetup(ctx, name, handlerMethod);
     ctx._("{0}.Item = item", name);
 }
开发者ID:InvertGames,项目名称:uFrame.ECS.Editor,代码行数:5,代码来源:CollectionItemRemovedNode.cs

示例10: WriteEventSubscription

        public virtual void WriteEventSubscription(TemplateContext ctx, CodeMemberMethod filterMethod, CodeMemberMethod handlerMethod)
        {

            if (!IsSystemEvent)
            {
                ctx._("this.OnEvent<{0}>().Subscribe(_=>{{ {1}(_); }}).DisposeWith(this)", EventType,
                    HandlerFilterMethodName);
            }
            else
            {
                var meta = Meta as EventMetaInfo;
                if (meta != null && ctx.IsDesignerFile)
                {
                    ctx.CurrentDeclaration.BaseTypes.Add(EventType);
                    var method = meta.SystemType.MethodFromTypeMethod(Meta.SystemEventMethod, false);
                    method._("{0}()", filterMethod.Name);
                    ctx.CurrentDeclaration.Members.Add(method);
                }

            }

        }
开发者ID:InvertGames,项目名称:uFrame.ECS.Editor,代码行数:22,代码来源:HandlerNode.cs

示例11: 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

示例12: WriteDebugInfo

        public virtual void WriteDebugInfo(TemplateContext ctx)
        {
            if (DebugSystem.IsDebugMode)
            {
                ctx._("while (this.DebugInfo(\"{0}\",\"{1}\", this) == 1) yield return null", LastSequenceItemId, this.Identifier);
                LastSequenceItemId = this.Identifier;
            }

        }
开发者ID:InvertGames,项目名称:uFrame.ECS.Editor,代码行数:9,代码来源:SequenceItemNode.cs

示例13: 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

示例14: WriteActionOutputs

        public override void WriteActionOutputs(TemplateContext _)
        {
            base.WriteActionOutputs(_);
            foreach (var item in Outputs)
            {
                var v = item.InputFrom<IContextVariable>();
                _._("{0} = {1}",item.Name, v.VariableName);
            }


        }
开发者ID:InvertGames,项目名称:uFrame.ECS.Editor,代码行数:11,代码来源:CustomActionNode.cs

示例15: WriteCode

        public override void WriteCode(ISequenceVisitor visitor, TemplateContext ctx)
        {
            base.WriteCode(visitor, ctx);
            foreach (var item in Outputs)
            {
                var v = item.InputFrom<IContextVariable>();
                if (v != null)
                ctx._("{0} = {1}", item.Name, v.VariableName);
            }

        }
开发者ID:InvertGames,项目名称:uFrame.ECS.Editor,代码行数:11,代码来源:CustomActionNode.cs


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