本文整理汇总了C#中TemplateContext.PopStatements方法的典型用法代码示例。如果您正苦于以下问题:C# TemplateContext.PopStatements方法的具体用法?C# TemplateContext.PopStatements怎么用?C# TemplateContext.PopStatements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TemplateContext
的用法示例。
在下文中一共展示了TemplateContext.PopStatements方法的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);
}
示例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;
}
示例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;
}
示例4: EndWriteLoop
public virtual void EndWriteLoop(TemplateContext ctx)
{
ctx.PopStatements();
}