当前位置: 首页>>代码示例>>C#>>正文


C# MemberDeclarationSyntax.CSharpKind方法代码示例

本文整理汇总了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;
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:22,代码来源:EventGenerator.cs

示例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);
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:14,代码来源:EventGenerator.cs

示例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;
            }
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:16,代码来源:NamedTypeGenerator.cs

示例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());
 }
开发者ID:LaxLacks,项目名称:ls2csc,代码行数:61,代码来源:TypeExtraInfo.cs


注:本文中的MemberDeclarationSyntax.CSharpKind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。