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


C# MethodDeclarationSyntax.GetTrailingTrivia方法代码示例

本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.MethodDeclarationSyntax.GetTrailingTrivia方法的典型用法代码示例。如果您正苦于以下问题:C# MethodDeclarationSyntax.GetTrailingTrivia方法的具体用法?C# MethodDeclarationSyntax.GetTrailingTrivia怎么用?C# MethodDeclarationSyntax.GetTrailingTrivia使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.CodeAnalysis.CSharp.Syntax.MethodDeclarationSyntax的用法示例。


在下文中一共展示了MethodDeclarationSyntax.GetTrailingTrivia方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Trivia

 public static MethodDeclarationSyntax Trivia(this MethodDeclarationSyntax node, MethodDeclarationSyntax that)
 {
     return node.WithLeadingTrivia(that.GetLeadingTrivia()).WithTrailingTrivia(that.GetTrailingTrivia());
 }
开发者ID:marcoparenzan,项目名称:CSharpDay2015,代码行数:4,代码来源:TriviaExtension.cs

示例2: TransverseMethods

        //private object TransverseClassTypes(object classType)
        //{
        //    object retObj;
        //    if (classType is ClassDeclarationSyntax)
        //    {
        //        retObj = new Class();
        //        classType = classType as ClassDeclarationSyntax;
        //    }
        //    else if (classType is StructDeclarationSyntax)
        //    {
        //        retObj = new Struct();
        //        classType = classType as StructDeclarationSyntax;
        //    }
        //        //Class retObj = new Class();
        //        //Name
        //        (retObj is Class ? retObj as Class : retObj as Struct).Name = (classType is ClassDeclarationSyntax ? (ClassDeclarationSyntax)classType : (StructDeclarationSyntax)classType).Identifier.ValueText;
        //        //encapsulation
        //        foreach (SyntaxToken st in classType.Modifiers)
        //        {
        //            string modifier = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(st.ValueText);
        //            retObj.Encapsulation.Add((Encapsulation)System.Enum.Parse(typeof(Encapsulation), modifier));
        //        }
        //        var enums = from aEnu in classType.ChildNodes().OfType<EnumDeclarationSyntax>() select aEnu;
        //        foreach (EnumDeclarationSyntax eds in enums)
        //        {
        //            retObj.Enums.Add(TraverseEnums(eds));
        //        }
        //        var structs = from aStruct in classType.ChildNodes().OfType<StructDeclarationSyntax>() select aStruct;
        //        foreach (StructDeclarationSyntax sds in structs)
        //        {
        //            retObj.Structs.Add(TransverseStructs(sds));
        //        }
        //        var methods = from aMethod in classType.ChildNodes().OfType<MethodDeclarationSyntax>() select aMethod;
        //        foreach (MethodDeclarationSyntax mds in methods)
        //        {
        //            retObj.Methods.Add(TransverseMethods(mds));
        //        }
        //        var fields = from aField in classType.ChildNodes().OfType<FieldDeclarationSyntax>() select aField;
        //        foreach (FieldDeclarationSyntax fds in fields)
        //        {
        //            retObj.Attributes.Add(TransverseVariables(fds));
        //        }
        //        //var properties = from aProperty in classType.ChildNodes().OfType<PropertyDeclarationSyntax>() select aProperty;
        //        //foreach (PropertyDeclarationSyntax pds in properties)
        //        //{
        //        //    //traverse attributes
        //        //}
        //        var constructors = from aConstructor in classType.ChildNodes().OfType<ConstructorDeclarationSyntax>() select aConstructor;
        //        foreach (ConstructorDeclarationSyntax cods in constructors)
        //        {
        //            retObj.Constructors.Add(TransverseConstructors(cods));
        //        }
        //        var destructors = from aDestructor in classType.ChildNodes().OfType<DestructorDeclarationSyntax>() select aDestructor;
        //        foreach (DestructorDeclarationSyntax dds in destructors)
        //        {
        //            retObj.Destructors.Add(TransverseDestructors(dds));
        //        }
        //        var classes = from aClass in classType.ChildNodes().OfType<ClassDeclarationSyntax>() select aClass;
        //        foreach (ClassDeclarationSyntax classType2 in classes)
        //        {
        //            retObj.Classes.Add(TraverseClass(classType2));
        //        }
        //        return retObj;
        //}
        private Method TransverseMethods(MethodDeclarationSyntax mds)
        {
            Method retMethod = new Method();
            //public int DecisionsCount { get; }
            //public int ExitPoints { get; set; }
            //public bool IsFriend { get; }
            //public bool IsPolymophic { get; }
            //public bool IsPublic { get; }
            //public bool IsStatic { get; }
            //public List<Preprocessor> Preprocessors { get; set; }
            retMethod.Name = mds.Identifier.ValueText;

            if (mds.HasLeadingTrivia)
            {
                SetOuterComments(retMethod, mds.GetLeadingTrivia().ToFullString());
            }

            if (mds.HasTrailingTrivia)
            {
                SetInnerComments(retMethod, mds.GetTrailingTrivia().ToFullString());
            }

            foreach (SyntaxToken st in mds.Modifiers)
            {
                string modifier = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(st.ValueText);
                Encapsulation encap;
                Qualifiers qual;
                if (System.Enum.TryParse<Encapsulation>(modifier, out encap))
                {
                    retMethod.Encapsulation.Add(encap);
                }
                else if (System.Enum.TryParse<Qualifiers>(modifier, out qual))
                {
                    retMethod.Qualifiers.Add(qual);
                }
            }
//.........这里部分代码省略.........
开发者ID:Zenoware,项目名称:RoslynParser,代码行数:101,代码来源:RoslynCSharpParser.cs


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