本文整理汇总了C#中MemberDeclarationSyntax.CSharpKind方法的典型用法代码示例。如果您正苦于以下问题:C# MemberDeclarationSyntax.CSharpKind方法的具体用法?C# MemberDeclarationSyntax.CSharpKind怎么用?C# MemberDeclarationSyntax.CSharpKind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemberDeclarationSyntax
的用法示例。
在下文中一共展示了MemberDeclarationSyntax.CSharpKind方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AfterMember
private static MemberDeclarationSyntax AfterMember(
SyntaxList<MemberDeclarationSyntax> members,
MemberDeclarationSyntax eventDeclaration)
{
if (eventDeclaration.CSharpKind() == 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.CSharpKind() == 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: BeforeMember
private static MemberDeclarationSyntax BeforeMember(
SyntaxList<MemberDeclarationSyntax> members,
MemberDeclarationSyntax eventDeclaration)
{
// If it's a field style event, then it goes before everything else if we don't have any
// existing fields/events.
if (eventDeclaration.CSharpKind() == SyntaxKind.FieldDeclaration)
{
return members.FirstOrDefault();
}
// Otherwise just place it before the methods.
return FirstMethod(members);
}
示例3: RemoveAllMembers
private static MemberDeclarationSyntax RemoveAllMembers(MemberDeclarationSyntax declaration)
{
switch (declaration.CSharpKind())
{
case SyntaxKind.EnumDeclaration:
return ((EnumDeclarationSyntax)declaration).WithMembers(default(SeparatedSyntaxList<EnumMemberDeclarationSyntax>));
case SyntaxKind.StructDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.ClassDeclaration:
return ((TypeDeclarationSyntax)declaration).WithMembers(default(SyntaxList<MemberDeclarationSyntax>));
default:
return declaration;
}
}
示例4: AddMember
public void AddMember(MemberDeclarationSyntax node)
{
switch (node.CSharpKind())
{
case SyntaxKind.ConstructorDeclaration:
{
Add((ConstructorDeclarationSyntax)node);
return;
}
break;
case SyntaxKind.FieldDeclaration:
{
Add((FieldDeclarationSyntax)node);
return;
}
break;
case SyntaxKind.EventFieldDeclaration:
{
Add((EventFieldDeclarationSyntax)node);
return;
}
break;
case SyntaxKind.PropertyDeclaration:
{
Add((PropertyDeclarationSyntax)node);
return;
}
break;
case SyntaxKind.MethodDeclaration:
{
Add((MethodDeclarationSyntax)node);
return;
}
break;
case SyntaxKind.EnumMemberDeclaration:
{
Add((EnumMemberDeclarationSyntax)node);
return;
}
break;
case SyntaxKind.IndexerDeclaration:
{
Add((IndexerDeclarationSyntax)node);
return;
}
break;
case SyntaxKind.ClassDeclaration:
{
Add((ClassDeclarationSyntax)node);
return;
}
break;
case SyntaxKind.StructDeclaration:
{
Add((StructDeclarationSyntax)node);
return;
}
break;
}
throw new NotImplementedException(node.CSharpKind().ToString());
}