本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.SyntaxList.LastOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxList.LastOrDefault方法的具体用法?C# SyntaxList.LastOrDefault怎么用?C# SyntaxList.LastOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Syntax.SyntaxList
的用法示例。
在下文中一共展示了SyntaxList.LastOrDefault方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AfterMember
private static MemberDeclarationSyntax AfterMember(
SyntaxList<MemberDeclarationSyntax> members,
MemberDeclarationSyntax eventDeclaration)
{
if (eventDeclaration.Kind() == SyntaxKind.EventFieldDeclaration)
{
// Field style events go after the last field event, or after the last field.
var lastEvent = members.LastOrDefault(m => m is EventFieldDeclarationSyntax);
return lastEvent ?? LastField(members);
}
if (eventDeclaration.Kind() == SyntaxKind.EventDeclaration)
{
// Property style events go after existing events, then after existing constructors.
var lastEvent = members.LastOrDefault(m => m is EventDeclarationSyntax);
return lastEvent ?? LastConstructor(members);
}
return null;
}
示例2: CreateSectionStatements
private static SyntaxList<StatementSyntax> CreateSectionStatements(StatementSyntax source)
{
var result = new SyntaxList<StatementSyntax>();
if (source is BlockSyntax)
{
var block = source as BlockSyntax;
result = result.AddRange(block.Statements);
}
else
{
result = result.Add(source);
}
var lastStatement = result.LastOrDefault();
if (!(lastStatement is ReturnStatementSyntax || lastStatement is ThrowStatementSyntax))
{
result = result.Add(SyntaxFactory.BreakStatement());
}
return result;
}
示例3: LastPropertyOrField
private static MemberDeclarationSyntax LastPropertyOrField(
SyntaxList<MemberDeclarationSyntax> members)
{
var lastProperty = members.LastOrDefault(m => m is PropertyDeclarationSyntax);
return lastProperty ?? LastField(members);
}