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


C# NamespaceDeclaration.GetAliasNamed方法代码示例

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


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

示例1: ResolveUsing

 //^ ensures result == null || result is ITypeDefinition || result is INamespaceDefinition || result is ITypeGroup ||
 //^ (!restrictToNamespacesAndTypes && result is INamespaceMember);
 /// <summary>
 /// Returns either null or the namespace member (group) that binds to this name. 
 /// This implementation of this method ignores global methods and variables, as is the case for C#. //TODO: is this really the case?
 /// </summary>
 /// <param name="namespaceDeclaration">The namespace to use to resolve this name.</param>
 /// <param name="restrictToNamespacesAndTypes">True if only namespaces and types should be considered when resolving this name.</param>
 /*?*/
 protected override object ResolveUsing(NamespaceDeclaration namespaceDeclaration, bool restrictToNamespacesAndTypes)
 {
     // Overrides the SimpleName's corresponding method so that we can handle the scope encoding
       // (the mangled C type names to encode scope information)
       string lookupNameString = this.Name.Value;
       // loop until we have tried every parent scope
       while (true) {
     IScope<INamespaceMember> scope = namespaceDeclaration.UnitNamespace;
     IName lookupName = this.NameTable.GetNameFor(lookupNameString);
     AliasDeclaration/*?*/ aliasDeclaration = null;
     UnitSetAliasDeclaration/*?*/ unitSetAliasDeclaration = null;
     if (!this.NamespaceDeclIsBusy(namespaceDeclaration))
       namespaceDeclaration.GetAliasNamed(lookupName, this.IgnoreCase, ref aliasDeclaration, ref unitSetAliasDeclaration);
     IEnumerable<INamespaceMember> members = scope.GetMembersNamed(lookupName, this.IgnoreCase);
     INamespaceTypeDefinition/*?*/ namespaceTypeDefinition = null;
     INamespaceDefinition/*?*/ nestedNamespaceDefinition = null;
     foreach (INamespaceMember member in members) {
       nestedNamespaceDefinition = member as INamespaceDefinition;
       if (nestedNamespaceDefinition != null) {
     //TODO: if aliasDeclaration != null give an ambiguous reference error
     return nestedNamespaceDefinition;
       }
       if (namespaceTypeDefinition == null) {
     namespaceTypeDefinition = member as INamespaceTypeDefinition;
     if (namespaceTypeDefinition != null && (aliasDeclaration == null || namespaceTypeDefinition.IsGeneric)) break;
     //carry on in case there is a generic type with this name. If not there is an ambiguity between the type and the alias.
       }
     }
     if (namespaceTypeDefinition != null) {
       //TODO: if aliasDeclaration != null give an ambiguous reference error if namespaceTypeDef is not generic
       if (this.Name.Value == lookupNameString) {
     return new NamespaceTypeGroup(this, scope, this);
       }
       VccSimpleName newSimpleName = new VccSimpleName(lookupName, this.sourceLocation);
       newSimpleName.SetContainingBlock(this.ContainingBlock);
       return new NamespaceTypeGroup(this, scope, newSimpleName);
     }
     if (this.NamespaceDeclIsBusy(namespaceDeclaration)) {
       //Have to ignore using statements.
       scope = namespaceDeclaration.UnitSetNamespace;
       members = scope.GetMembersNamed(lookupName, this.IgnoreCase);
     } else {
       if (aliasDeclaration != null) return aliasDeclaration.ResolvedNamespaceOrType;
       if (unitSetAliasDeclaration != null) {
     IUnitSetNamespace usns = unitSetAliasDeclaration.UnitSet.UnitSetNamespaceRoot;
     //^ assume usns is INamespaceDefinition; //IUnitSetNamespace : INamespaceDefinition
     return usns;
       }
       scope = namespaceDeclaration.Scope;
       members = scope.GetMembersNamed(lookupName, this.IgnoreCase); //Considers types that were imported into the namespace via using statements
     }
     foreach (INamespaceMember member in members) {
       if (nestedNamespaceDefinition == null) nestedNamespaceDefinition = member as INamespaceDefinition;
       namespaceTypeDefinition = member as INamespaceTypeDefinition;
       if (namespaceTypeDefinition != null) return new NamespaceTypeGroup(this, scope, this);
     }
     if (nestedNamespaceDefinition != null) return nestedNamespaceDefinition;
     // Test to see if we have reached the outermost scope, in which case lookupNameString
     // is not a mangled one.
     if (!lookupNameString.Contains("^")) break;
     lookupNameString = LexicalScope.LexicalScopeOf(lookupNameString) == "" ? LexicalScope.UnmangledName(lookupNameString) : LexicalScope.MangledNameWithOuterLexcialScope(lookupNameString);
       }
       // The following (looking the name up in the nested namespace)
       // may not apply to the C case. Keep it here anyway.
       NestedNamespaceDeclaration/*?*/ nestedNamespace = namespaceDeclaration as NestedNamespaceDeclaration;
       if (nestedNamespace != null) return this.ResolveUsing(nestedNamespace.ContainingNamespaceDeclaration, restrictToNamespacesAndTypes);
       return null;
 }
开发者ID:edgar-pek,项目名称:VCDryad,代码行数:77,代码来源:Expressions.cs


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