本文整理汇总了C#中Compilation.GetCompilationNamespace方法的典型用法代码示例。如果您正苦于以下问题:C# Compilation.GetCompilationNamespace方法的具体用法?C# Compilation.GetCompilationNamespace怎么用?C# Compilation.GetCompilationNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Compilation
的用法示例。
在下文中一共展示了Compilation.GetCompilationNamespace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TranslateNamespaces
/// <summary>
/// Makes certain all namespace symbols returned by API are from the compilation.
/// </summary>
private static IEnumerable<ISymbol> TranslateNamespaces(List<ISymbol> symbols, Compilation compilation)
{
foreach (var symbol in symbols)
{
var ns = symbol as INamespaceSymbol;
if (ns != null)
{
yield return compilation.GetCompilationNamespace(ns);
}
else
{
yield return symbol;
}
}
}
示例2: GetContainers
private static IEnumerable<INamespaceOrTypeSymbol> GetContainers(IEnumerable<ISymbol> symbols, Compilation compilation)
{
foreach (var symbol in symbols)
{
var containingSymbol = symbol.ContainingSymbol as INamespaceOrTypeSymbol;
if (containingSymbol is INamespaceSymbol)
{
containingSymbol = compilation.GetCompilationNamespace((INamespaceSymbol)containingSymbol);
}
if (containingSymbol != null)
{
yield return containingSymbol;
}
}
}
示例3: TranslateNamespaces
/// <summary>
/// Makes certain all namespace symbols returned by API are from the compilation.
/// </summary>
private static ImmutableArray<ISymbol> TranslateNamespaces(
ImmutableArray<ISymbol> symbols, Compilation compilation)
{
var builder = ArrayBuilder<ISymbol>.GetInstance();
foreach (var symbol in symbols)
{
var ns = symbol as INamespaceSymbol;
if (ns != null)
{
builder.Add(compilation.GetCompilationNamespace(ns));
}
else
{
builder.Add(symbol);
}
}
var result = builder.Count == symbols.Length
? symbols
: builder.ToImmutable();
builder.Free();
return result;
}