本文整理汇总了C#中Statement.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Statement.Clone方法的具体用法?C# Statement.Clone怎么用?C# Statement.Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Statement
的用法示例。
在下文中一共展示了Statement.Clone方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateNewTrueStatement
static Statement GenerateNewTrueStatement(Statement falseStatement)
{
var blockStatement = falseStatement as BlockStatement;
if (blockStatement != null) {
if (blockStatement.Children.Count(n => n.Role != Roles.NewLine && n.Role != Roles.LBrace && n.Role != Roles.RBrace) == 1)
return blockStatement.Statements.First().Clone ();
}
return falseStatement.Clone();
}
示例2: GetLoopBlock
private Statement GetLoopBlock(Statement statement)
{
this.blockIds.Enqueue (this.id++);
BlockStatement block = statement as BlockStatement;
if (block == null)
{
if (statement == Statement.Null)
block = new BlockStatement();
else
block = new BlockStatement { statement.Clone() };
}
var beginExpression = GetHookExpression ("BeginInsideLoop", GetSubmissionId(), GetId());
if (block.FirstChild != null)
block.InsertBefore (block.FirstChild, beginExpression);
else
block.Add (beginExpression);
block.Add (GetHookExpression ("EndInsideLoop", GetSubmissionId(), GetId()));
return block;
}
示例3: GetActions
IEnumerable<CodeAction> GetActions(Statement oldStatement, Statement followingStatement)
{
yield return new CodeAction(context.TranslateString("Move to nested scope"), script => {
var parent = followingStatement.Parent;
if (parent is SwitchSection || parent is BlockStatement) {
script.InsertBefore(followingStatement, oldStatement.Clone());
} else {
var newBlockStatement = new BlockStatement {
Statements = {
oldStatement.Clone(),
followingStatement.Clone()
}
};
script.Replace(followingStatement, newBlockStatement);
script.FormatText(parent);
}
script.Remove(oldStatement);
});
}
示例4: GetLoopBlock
private Statement GetLoopBlock(Statement statement)
{
this.blockIds.Enqueue (this.id++);
BlockStatement block = statement as BlockStatement;
if (block == null)
{
if (statement == Statement.Null)
block = new BlockStatement();
else
block = new BlockStatement { statement.Clone() };
}
this.id += 2;
return block;
}