本文整理汇总了C#中INamespaceSymbol类的典型用法代码示例。如果您正苦于以下问题:C# INamespaceSymbol类的具体用法?C# INamespaceSymbol怎么用?C# INamespaceSymbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
INamespaceSymbol类属于命名空间,在下文中一共展示了INamespaceSymbol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
// The containing symbol can be one of many things.
// 1) Null when this is the global namespace for a compilation.
// 2) The SymbolId for an assembly symbol if this is the global namespace for an
// assembly.
// 3) The SymbolId for a module symbol if this is the global namespace for a module.
// 4) The SymbolId for the containing namespace symbol if this is not a global
// namespace.
public static void Create(INamespaceSymbol symbol, SymbolKeyWriter visitor)
{
visitor.WriteString(symbol.MetadataName);
if (symbol.ContainingNamespace != null)
{
visitor.WriteBoolean(false);
visitor.WriteSymbolKey(symbol.ContainingNamespace);
}
else
{
// A global namespace can either belong to a module or to a compilation.
Debug.Assert(symbol.IsGlobalNamespace);
switch (symbol.NamespaceKind)
{
case NamespaceKind.Module:
visitor.WriteBoolean(false);
visitor.WriteSymbolKey(symbol.ContainingModule);
break;
case NamespaceKind.Assembly:
visitor.WriteBoolean(false);
visitor.WriteSymbolKey(symbol.ContainingAssembly);
break;
case NamespaceKind.Compilation:
visitor.WriteBoolean(true);
visitor.WriteSymbolKey(null);
break;
default:
throw new NotImplementedException();
}
}
}
示例2: Map
public IUnitNamespaceReference Map(INamespaceSymbol namespaceSymbol) {
Contract.Requires(namespaceSymbol != null);
Contract.Ensures(Contract.Result<IUnitNamespaceReference>() != null);
IUnitNamespaceReference nsr = null;
if (!namespaceSymbolCache.TryGetValue(namespaceSymbol, out nsr)) {
if (namespaceSymbol.ContainingAssembly.Equals(this.assemblyBeingTranslated)) {
var n = this.CreateNamespaceDefinition(namespaceSymbol);
return n;
}
if (namespaceSymbol.IsGlobalNamespace) {
var n = new Microsoft.Cci.MutableCodeModel.RootUnitNamespaceReference() {
Unit = Map(namespaceSymbol.ContainingAssembly),
};
nsr = n;
} else {
var ns = new Microsoft.Cci.MutableCodeModel.NestedUnitNamespaceReference() {
ContainingUnitNamespace = Map(namespaceSymbol.ContainingNamespace),
Name = this.nameTable.GetNameFor(namespaceSymbol.Name),
};
nsr = ns;
}
namespaceSymbolCache[namespaceSymbol] = nsr;
}
Contract.Assume(nsr != null);
return nsr;
}
示例3: GetParsedNamespace
private SDNamespace GetParsedNamespace(INamespaceSymbol namespaceSymbol)
{
var descriptionFiles = _descriptionFiles.Where(d => Path.GetFileName(d).ToLower().Contains(namespaceSymbol.Name.ToLower() + ".sdnd"));
var descriptions = new SDLanguageItemCollection<SDTemplate>();
foreach (var file in descriptionFiles)
{
if (!string.IsNullOrEmpty(namespaceSymbol.Name.Trim()))
{
var splitted = Path.GetFileName(file).ToLower().Replace(namespaceSymbol.Name.ToLower(), " ").Split('.');
if (splitted.Length > 0 && splitted[0].Length == 2 && CultureInfo.GetCultures(CultureTypes.AllCultures).Any(c => c.TwoLetterISOLanguageName == splitted[0]))
{
descriptions.Add(splitted[0], new SDTemplate(File.ReadAllText(file), ParserOptions.Tokens));
ExecuteOnDocLanguageFound(splitted[0].ToLower());
}
else if (splitted.Length > 0 && string.IsNullOrEmpty(splitted[0].Trim()))
{
descriptions.Add("default", new SDTemplate(File.ReadAllText(file), ParserOptions.Tokens));
}
}
}
return new SDNamespace(namespaceSymbol.GetIdentifier())
{
Assemblyname = namespaceSymbol.ContainingAssembly.Name,
Descriptions = descriptions
};
}
示例4: VisitNamespace
public override void VisitNamespace(INamespaceSymbol symbol)
{
foreach (var member in symbol.GetMembers())
{
member.Accept(this);
}
}
示例5: Attach
public static void Attach(
INamespaceSymbol @namespace,
IList<ISymbol> imports)
{
var info = new CodeGenerationNamespaceInfo(imports ?? SpecializedCollections.EmptyList<ISymbol>());
namespaceToInfoMap.Add(@namespace, info);
}
示例6: VisitNamespace
public override void VisitNamespace(INamespaceSymbol symbol)
{
ReferenceItem.Parts[SyntaxLanguage.CSharp].Add(new LinkItem
{
DisplayName = NameVisitorCreator.GetCSharp(NameOptions.None).GetName(symbol),
DisplayQualifiedNames = NameVisitorCreator.GetCSharp(NameOptions.Qualified).GetName(symbol),
});
}
示例7: AddNamespaceOrTypeDeclarationAsync
public static Task<Document> AddNamespaceOrTypeDeclarationAsync(Solution solution, INamespaceSymbol destination, INamespaceOrTypeSymbol namespaceOrType, CodeGenerationOptions options = default(CodeGenerationOptions), CancellationToken cancellationToken = default(CancellationToken))
{
try {
return (Task<Document>)addNamespaceOrTypeDeclarationAsyncMethod.Invoke (null, new object[] { solution, destination, namespaceOrType, options != null ? options.Instance : null, cancellationToken });
} catch (TargetInvocationException ex) {
ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
return null;
}
}
示例8: Create
internal static EnvDTE.CodeElements Create(
CodeModelState state,
object parent,
ProjectId projectId,
INamespaceSymbol namespaceSymbol)
{
var collection = new ExternalNamespaceCollection(state, parent, projectId, namespaceSymbol);
return (EnvDTE.CodeElements)ComAggregate.CreateAggregatedObject(collection);
}
示例9: VisitNamespace
public override void VisitNamespace(INamespaceSymbol symbol)
{
symbols.Add(symbol);
foreach (var childSymbol in symbol.GetMembers())
{
childSymbol.Accept(this);
}
}
示例10: CreateForNamespace
public IVsNavInfo CreateForNamespace(INamespaceSymbol namespaceSymbol, Project project, Compilation compilation, bool useExpandedHierarchy = false)
{
return Create(
namespaceSymbol.ContainingAssembly,
project,
compilation,
useExpandedHierarchy,
namespaceName: GetNamespaceName(namespaceSymbol));
}
示例11: CollectTypes
private static void CollectTypes(INamespaceSymbol ns, List<ITypeSymbol> types)
{
types.AddRange(ns.GetTypeMembers().Cast<ITypeSymbol>());
foreach (var nestedNs in ns.GetNamespaceMembers())
{
CollectTypes(nestedNs, types);
}
}
示例12: GetNameParts
private static void GetNameParts(INamespaceSymbol namespaceSymbol, List<string> result)
{
if (namespaceSymbol == null || namespaceSymbol.IsGlobalNamespace)
{
return;
}
GetNameParts(namespaceSymbol.ContainingNamespace, result);
result.Add(namespaceSymbol.Name);
}
示例13: GetFullName
/// <summary>
/// Get the full name of a namespace. i.e. "OuterNamespace.Inner.ClassName"
/// </summary>
/// <param name="namespaceSymbol">namespace to get name of</param>
/// <returns>Full display name for a namespaceSymbol</returns>
internal static string GetFullName(INamespaceSymbol namespaceSymbol)
{
if (namespaceSymbol.ContainingNamespace != null &&
!namespaceSymbol.ContainingNamespace.IsGlobalNamespace)
{
return GetFullName(namespaceSymbol.ContainingNamespace) + "." + namespaceSymbol.Name;
}
return namespaceSymbol.Name;
}
示例14: AddNamespaceLink
protected void AddNamespaceLink(INamespaceSymbol namespaceSymbol)
{
if (namespaceSymbol.IsGlobalNamespace)
{
return;
}
var text = namespaceSymbol.ToDisplayString();
var navInfo = _libraryManager.GetNamespaceNavInfo(namespaceSymbol, _project, GetCompilation(), useExpandedHierarchy: false);
_description.AddDescriptionText3(text, VSOBDESCRIPTIONSECTION.OBDS_TYPE, navInfo);
}
示例15: Visit
private void Visit(INamespaceSymbol nameSpace)
{
foreach (var type in nameSpace.GetTypeMembers())
{
Visit(type);
}
foreach (var innerNameSpace in nameSpace.GetNamespaceMembers())
{
Visit(innerNameSpace);
}
}