本文整理匯總了C#中BlockSyntax.ReplaceNodes方法的典型用法代碼示例。如果您正苦於以下問題:C# BlockSyntax.ReplaceNodes方法的具體用法?C# BlockSyntax.ReplaceNodes怎麽用?C# BlockSyntax.ReplaceNodes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類BlockSyntax
的用法示例。
在下文中一共展示了BlockSyntax.ReplaceNodes方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: UpdateMethodBody
private BlockSyntax UpdateMethodBody(BlockSyntax blockSyntax, TypeSyntax returnTypeSyntax, ParameterListSyntax parameterListSyntax)
{
if (blockSyntax != null)
{
//var specialType = _typeTranslation.FirstOrDefault(tt => ExtractRoslynSymbol(tt.ActualType).ToDisplayString() == returnTypeSyntax.ToFullString().Replace("global::", ""));
var specialType = _typeTranslation.FirstOrDefault(tt => PrettyTypeName(tt.ActualType) == returnTypeSyntax.ToFullString().Replace("global::", ""));
if (specialType != null)
{
blockSyntax = SyntaxFactory.Block(
blockSyntax.Statements.Select(s => s.IsKind(SyntaxKind.ReturnStatement) ?
WrapReturnStatement(s as ReturnStatementSyntax, specialType) :
s
).ToArray());
}
var parameterIdentifierNodes = blockSyntax.DescendantNodes()
.OfType<IdentifierNameSyntax>()
.Where(i => parameterListSyntax.Parameters
.Any(p => p.Identifier.ToFullString() == i.ToFullString()));
blockSyntax = blockSyntax.ReplaceNodes(parameterIdentifierNodes, (originalNode, rewrittenNode) => WrapForwardedIdentifier(rewrittenNode, parameterListSyntax));
}
return blockSyntax;
}