本文整理汇总了C#中RenderContext.NeedSpaceIf方法的典型用法代码示例。如果您正苦于以下问题:C# RenderContext.NeedSpaceIf方法的具体用法?C# RenderContext.NeedSpaceIf怎么用?C# RenderContext.NeedSpaceIf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderContext
的用法示例。
在下文中一共展示了RenderContext.NeedSpaceIf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public override bool Render(RenderContext dest)
{
switch (Op)
{
case Token.kw_typeof:
case Token.kw_void:
case Token.kw_delete:
dest.Append(Op.ToString().Substring(3));
break;
case Token.add:
break;
case Token.subtract:
dest.Append('-');
dest.NeedSpaceIf('-');
break;
case Token.bitwiseNot:
case Token.logicalNot:
case Token.increment:
case Token.decrement:
dest.Append(Tokenizer.FormatToken(Op));
break;
default:
System.Diagnostics.Debug.Assert(false);
break;
}
// RHS
WrapAndRender(dest, Rhs, false);
return true;
}
示例2: Render
public override bool Render(RenderContext dest)
{
// LHS
WrapAndRender(dest, Lhs, false);
foreach (var t in Terms)
{
// Operator
switch (t.Op)
{
case Token.add:
dest.Append("+");
// Prevent `lhs + ++rhs` from becoming `lhs+++rhs` (which would incorrectly be interpreted as `lhs++ + rhs`)
dest.NeedSpaceIf('+');
break;
case Token.subtract:
dest.Append("-");
// Prevent `lhs - --rhs` from becoming `lhs---rhs` (which would incorrectly be interpreted as `lhs-- - rhs`)
// Also prevent `lhs- -rhs` from become `lhs--rhs` (which would incorrectly be interpreted as `lhs-- rhs`)
dest.NeedSpaceIf('-');
break;
case Token.multiply:
case Token.divide:
case Token.modulus:
case Token.shl:
case Token.shr:
case Token.shrz:
case Token.compareEQ:
case Token.compareNE:
case Token.compareLT:
case Token.compareLE:
case Token.compareGT:
case Token.compareGE:
case Token.compareEQStrict:
case Token.compareNEStrict:
case Token.bitwiseXor:
case Token.bitwiseOr:
case Token.bitwiseAnd:
case Token.logicalOr:
case Token.logicalAnd:
case Token.kw_in:
case Token.kw_instanceof:
dest.Append(Tokenizer.FormatToken(t.Op));
break;
default:
System.Diagnostics.Debug.Assert(false);
break;
}
// RHS
WrapAndRender(dest, t.Rhs, true);
}
return true;
}