本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.MethodDeclarationSyntax.ContainingClass方法的典型用法代码示例。如果您正苦于以下问题:C# MethodDeclarationSyntax.ContainingClass方法的具体用法?C# MethodDeclarationSyntax.ContainingClass怎么用?C# MethodDeclarationSyntax.ContainingClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Syntax.MethodDeclarationSyntax
的用法示例。
在下文中一共展示了MethodDeclarationSyntax.ContainingClass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeclaredIdentifiers
private static IEnumerable<string> DeclaredIdentifiers(MethodDeclarationSyntax syntax)
{
var methodParameterNames = syntax.ParameterList.Parameters
.Select(p => p.Identifier.ValueText);
var methodLocalVars = syntax
.DescendantNodes()
.OfType<LocalDeclarationStatementSyntax>()
.SelectMany(d => d.Declaration.Variables)
.Select(v => v.Identifier.ValueText);
var classFieldIds = syntax.ContainingClass()
.DescendantNodes()
.OfType<FieldDeclarationSyntax>()
.SelectMany(f => f.Declaration.Variables)
.Select(v => v.Identifier.ValueText);
var classPropertyIds = syntax.ContainingClass()
.DescendantNodes()
.OfType<PropertyDeclarationSyntax>()
.Select(p => p.Identifier.ValueText);
var classMethodIds = syntax.ContainingClass()
.DescendantNodes()
.OfType<MethodDeclarationSyntax>()
.Select(m => m.Identifier.ValueText);
var classDelegateIds = syntax.ContainingClass()
.DescendantNodes()
.OfType<DelegateDeclarationSyntax>()
.Select(d => d.Identifier.ValueText);
return methodParameterNames
.Concat(methodLocalVars)
.Concat(classFieldIds)
.Concat(classPropertyIds)
.Concat(classMethodIds)
.Concat(classDelegateIds);
}