本文整理汇总了C#中ISymbol.IsNamespace方法的典型用法代码示例。如果您正苦于以下问题:C# ISymbol.IsNamespace方法的具体用法?C# ISymbol.IsNamespace怎么用?C# ISymbol.IsNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISymbol
的用法示例。
在下文中一共展示了ISymbol.IsNamespace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsNonIntersectingNamespace
protected static bool IsNonIntersectingNamespace(
ISymbol recommendationSymbol, SyntaxNode declarationSyntax)
{
//
// Apart from filtering out non-namespace symbols, this also filters out the symbol
// currently being declared. For example...
//
// namespace X$$
//
// ...X won't show in the completion list (unless it is also declared elsewhere).
//
// In addition, in VB, it will filter out Bar from the sample below...
//
// Namespace Foo.$$
// Namespace Bar
// End Namespace
// End Namespace
//
// ...unless, again, it's also declared elsewhere.
//
return recommendationSymbol.IsNamespace() &&
recommendationSymbol.Locations.Any(
candidateLocation => !(declarationSyntax.SyntaxTree == candidateLocation.SourceTree &&
declarationSyntax.Span.IntersectsWith(candidateLocation.SourceSpan)));
}
示例2: TypeArgumentsInAllContainingSymbol
private void TypeArgumentsInAllContainingSymbol(ISymbol symbol, IList<ISymbol> typeArgumentSymbols, bool enterContainingSymbol, bool isRecursive)
{
if (symbol == null || symbol.IsNamespace())
{
// This is the terminating condition
return;
}
if (symbol is INamedTypeSymbol)
{
var namedTypedSymbol = (INamedTypeSymbol)symbol;
if (namedTypedSymbol.TypeArguments.Length != 0)
{
foreach (var typeArgument in namedTypedSymbol.TypeArguments)
{
if (!typeArgumentSymbols.Contains(typeArgument))
{
typeArgumentSymbols.Add(typeArgument);
if (isRecursive)
{
TypeArgumentsInAllContainingSymbol(typeArgument, typeArgumentSymbols, enterContainingSymbol, isRecursive);
}
}
}
}
}
if (enterContainingSymbol)
{
TypeArgumentsInAllContainingSymbol(symbol.ContainingSymbol, typeArgumentSymbols, enterContainingSymbol, isRecursive);
}
}