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


C# INamespaceSymbol.GetNamespaceMembers方法代码示例

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


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

示例1: 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);
            }
        }
开发者ID:leloulight,项目名称:Scaffolding,代码行数:9,代码来源:RoslynUtilities.cs

示例2: Visit

		private void Visit(INamespaceSymbol nameSpace)
		{
			foreach (var type in nameSpace.GetTypeMembers())
			{
				Visit(type);
			}

			foreach (var innerNameSpace in nameSpace.GetNamespaceMembers())
			{
				Visit(innerNameSpace);
			}
		}
开发者ID:tumtumtum,项目名称:Shaolinq,代码行数:12,代码来源:CompilationLookup.cs

示例3: ParseProjectNamespacesRecursively

        internal void ParseProjectNamespacesRecursively(INamespaceSymbol namespaceSymbol)
        {
            HandleOnItemParseStart(namespaceSymbol.Name);
            if (!ParserOptions.SharpDoxConfig.ExcludedIdentifiers.Contains(namespaceSymbol.GetIdentifier()))
            {
                var sdNamespace = GetParsedNamespace(namespaceSymbol);
                ParserOptions.SDRepository.AddNamespace(sdNamespace);
                _typeParser.ParseProjectTypes(namespaceSymbol.GetTypeMembers().ToList());
            }

            foreach (var childNamespaceSymbol in namespaceSymbol.GetNamespaceMembers())
            {
                ParseProjectNamespacesRecursively(childNamespaceSymbol);
            }
        }
开发者ID:Geaz,项目名称:sharpDox,代码行数:15,代码来源:NamespaceParser.cs

示例4: GetNamespace

        private static INamespaceSymbol GetNamespace(string nspace, INamespaceSymbol namespaceSymbol)
        {
            namespaceSymbol = namespaceSymbol.GetNamespaceMembers()
                .FirstOrDefault(ns =>
                    {
                        string fullNamespace = CodeAnalysisHelper.GetFullNamespace(ns);
                        return nspace == fullNamespace || nspace.StartsWith(fullNamespace + Type.Delimiter);
                    });

            if (namespaceSymbol != null && CodeAnalysisHelper.GetFullNamespace(namespaceSymbol) != nspace)
            {
                namespaceSymbol = CodeAnalysisHelper.GetNamespace(nspace, namespaceSymbol);
            }

            return namespaceSymbol;
        }
开发者ID:MichaelSimons,项目名称:visual-studio-tools,代码行数:16,代码来源:CodeAnalysisHelper.cs

示例5: VisitNamespace

        public override void VisitNamespace(INamespaceSymbol symbol)
        {
            if (_finished || _symbolPredicate == null || _symbolPredicate(symbol))
            {
                AddDocument(symbol, true, new MetadataItems
                {
                    { CodeAnalysisKeys.SpecificKind, (k, m) => symbol.Kind.ToString() },
                    { CodeAnalysisKeys.MemberNamespaces, DocumentsFor(symbol.GetNamespaceMembers()) },
                    { CodeAnalysisKeys.MemberTypes, DocumentsFor(symbol.GetTypeMembers()) }
                });
            }

            // Descend if not finished, regardless if this namespace was included
            if (!_finished)
            {
                Parallel.ForEach(symbol.GetMembers(), s => s.Accept(this));
            }
        }
开发者ID:martinvobr,项目名称:Wyam,代码行数:18,代码来源:AnalyzeSymbolVisitor.cs

示例6: GetAllTypesInModuleSymbol

 private static IEnumerable<ITypeSymbol> GetAllTypesInModuleSymbol(INamespaceSymbol symbol)
 {
     return Enumerable.Concat(symbol.GetTypeMembers(), symbol.GetNamespaceMembers().SelectMany(GetAllTypesInModuleSymbol));
 }
开发者ID:ElboNet,项目名称:dotvvm,代码行数:4,代码来源:CompletionHelper.cs

示例7: AddNamespacesFromCompilation

        private static void AddNamespacesFromCompilation(ConcurrentBag<string> namespaceNamesInCompilation, INamespaceSymbol @namespace)
        {
            namespaceNamesInCompilation.Add(@namespace.ToDisplayString());

            foreach (INamespaceSymbol namespaceMember in @namespace.GetNamespaceMembers())
            {
                AddNamespacesFromCompilation(namespaceNamesInCompilation, namespaceMember);
            }
        }
开发者ID:bkoelman,项目名称:roslyn-analyzers,代码行数:9,代码来源:TypeNamesShouldNotMatchNamespaces.cs

示例8: GetExportedTypes

        private static void GetExportedTypes(INamespaceSymbol namespaceSymbol, List<ITypeInfo> exportedTypes)
        {
            foreach (var type in namespaceSymbol.GetTypeMembers())
            {
                if (type.TypeKind == TypeKind.Class &&
                    type.DeclaredAccessibility == Accessibility.Public)
                {
                    exportedTypes.Add(new CodeAnalysisSymbolBasedTypeInfo(type));
                }
            }

            foreach (var subNamespace in namespaceSymbol.GetNamespaceMembers())
            {
                GetExportedTypes(subNamespace, exportedTypes);
            }
        }
开发者ID:huoxudong125,项目名称:Razor,代码行数:16,代码来源:PrecompilationTagHelperTypeResolver.cs

示例9: FillNamespaces

		public static void FillNamespaces (ITreeBuilder builder, Project project, INamespaceSymbol ns)
		{
			var members = ns.GetTypeMembers ();
			//IParserContext ctx = IdeApp.Workspace.ParserDatabase.GetProjectParserContext (project);
			if (members.Any ()) {
				if (builder.Options ["ShowProjects"])
					builder.AddChild (new ProjectNamespaceData (project, ns));
				else {
					if (!builder.HasChild (ns.Name, typeof (NamespaceData)))
						builder.AddChild (new ProjectNamespaceData (null, ns));
				}
			}
			foreach (var nSpace in ns.GetNamespaceMembers ()) {
				FillNamespaces (builder, project, nSpace);
			}
		}
开发者ID:xinfushe,项目名称:monodevelop,代码行数:16,代码来源:ProjectNodeBuilder.cs

示例10: VisitNamespace

 public override void VisitNamespace(INamespaceSymbol symbol)
 {
     base.VisitNamespace(symbol);
     foreach (var item in symbol.GetTypeMembers())
     {
         item.Accept(this);
     }
     foreach (var item in symbol.GetNamespaceMembers())
     {
         item.Accept(this);
     }
 }
开发者ID:x335,项目名称:WootzJs,代码行数:12,代码来源:SymbolWalker.cs

示例11: LookupNamespace

		static INamespaceSymbol LookupNamespace (string documentationCommentId, ref int reminder, INamespaceSymbol current)
		{
			var exact = documentationCommentId.IndexOf ('.', reminder) < 0;

			foreach (var subNamespace in current.GetNamespaceMembers ()) {
				if (exact) {
					if (subNamespace.Name.Length == documentationCommentId.Length - reminder &&
					    string.CompareOrdinal (documentationCommentId, reminder, subNamespace.Name, 0, subNamespace.Name.Length) == 0)
						return subNamespace;
				} else {
					if (subNamespace.Name.Length < documentationCommentId.Length - reminder - 1 &&
						string.CompareOrdinal (documentationCommentId, reminder, subNamespace.Name, 0, subNamespace.Name.Length) == 0 &&
						documentationCommentId [reminder + subNamespace.Name.Length] == '.') {
						reminder += subNamespace.Name.Length + 1;
						return LookupNamespace (documentationCommentId, ref reminder, subNamespace);
					}
				}
			}

			return current;
		}
开发者ID:sushihangover,项目名称:monodevelop,代码行数:21,代码来源:CSharpFindReferencesProvider.cs

示例12: ProcessNamespace


//.........这里部分代码省略.........
                            Name = typeName.Name,
                            FullName = typeFullName,
                            AssemblyName = assemblyName,
                            PackageName = _package.Id,
                            PackageVersion = _package.Version
                        };
                        newType.TargetFrameworks.AddRange(assembly.TargetFrameworks);

                        _types.Add(typeFullName, newType);

                        // if namespace contains at least one type and we meet this namespace first time - remember it
                        if (!string.IsNullOrEmpty(fullNamespaceName) && !_namespaces.ContainsKey(fullNamespaceName))
                        {
                            var newNamespace = new NamespaceModel
                            {
                                Name = fullNamespaceName,
                                AssemblyName = assemblyName,
                                PackageName = _package.Id,
                                PackageVersion = _package.Version
                            };
                            newNamespace.TargetFrameworks.AddRange(assembly.TargetFrameworks);

                            _namespaces.Add(fullNamespaceName, newNamespace);
                        }
                        else
                        {
                            var namespaceModel = _namespaces[fullNamespaceName];
                            namespaceModel.MergeTargetFrameworks(assembly.TargetFrameworks);
                        }
                    }
                    else
                    {
                        var typeModel = _types[typeFullName];
                        typeModel.MergeTargetFrameworks(assembly.TargetFrameworks);

                        if (!string.IsNullOrEmpty(fullNamespaceName))
                        {
                            var namespaceModel = _namespaces[fullNamespaceName];
                            namespaceModel.MergeTargetFrameworks(assembly.TargetFrameworks);
                        }
                    }

                    // if type is static, then it might contain extension methdos 
                    if (typeName.IsStatic)
                    {
                        foreach (var member in typeName.GetMembers())
                        {
                            // proceed only if static type's member is a method and it is public
                            var method = member as IMethodSymbol;
                            if (method == null || method.DeclaredAccessibility != Accessibility.Public)
                            {
                                continue;
                            }

                            if (method.IsExtensionMethod)
                            {
                                var thisParameter = method.Parameters[0];
                                var extensionMethodTypeName = thisParameter.Type.ContainingNamespace + "." + thisParameter.Type.Name;
                                var extensionFullName = extensionMethodTypeName + "." + method.Name;

                                // if we meet this extension first time - remember it
                                if (!_extensions.ContainsKey(extensionFullName))
                                {
                                    var newExtension = new ExtensionModel
                                    {
                                        Name = method.Name,
                                        FullName = extensionFullName,
                                        AssemblyName = assemblyName,
                                        PackageName = _package.Id,
                                        PackageVersion = _package.Version,
                                        Namespace = fullNamespaceName
                                    };
                                    newExtension.TargetFrameworks.AddRange(assembly.TargetFrameworks);

                                    _extensions.Add(extensionFullName, newExtension);
                                }
                                else
                                {
                                    var extensionModel = _extensions[extensionFullName];
                                    extensionModel.MergeTargetFrameworks(assembly.TargetFrameworks);
                                }
                            }
                        }
                    }
                }
                catch(Exception e)
                {
                    Debug.Write(e.ToString());
                }
            }

            // recurse to chilren namespaces
            foreach (var childNamespace in namespaceSymbol.GetNamespaceMembers())
            {
                if (childNamespace.NamespaceKind == NamespaceKind.Module)
                {
                    ProcessNamespace(assembly, childNamespace);
                }
            }
        }
开发者ID:digideskio,项目名称:NuGet.PackageIndex,代码行数:101,代码来源:RoslynReflector.cs

示例13: EnumSymbols

        private static void EnumSymbols(INamespaceSymbol namespaceSymbol, Action<ISymbol> action)
        {
            foreach (var subNamespace in namespaceSymbol.GetNamespaceMembers())
            {
                EnumSymbols(subNamespace, action);
            }

            foreach (var topLevelType in namespaceSymbol.GetTypeMembers())
            {
                action(topLevelType);
            }
        }
开发者ID:KirillOsenkov,项目名称:SourceBrowser,代码行数:12,代码来源:MetadataAsSource.cs

示例14: MapGlobalTypes

        internal static void MapGlobalTypes(NamespaceInfoMap nsInfoMap, INamespaceSymbol nsSymbol)
        {
            if (!nsSymbol.IsGlobalNamespace)
            {
                foreach (var nsInfo in nsInfoMap.Values)
                {
                    if (nsSymbol.FullNameEquals(nsInfo.DottedName.NameParts))
                    {
                        var typeSymbolList = nsSymbol.GetMembers().OfType<INamedTypeSymbol>().Where(i => i.TypeKind == Microsoft.CodeAnalysis.TypeKind.Class).ToList();
                        for (var i = 0; i < typeSymbolList.Count;)
                        {
                            var typeSymbol = typeSymbolList[i];
                            var clsAttData = typeSymbol.GetAttributeData(SchemaClassAttributeNameParts);
                            if (clsAttData != null)
                            {
                                if (typeSymbol.IsGenericType)
                                {
                                    CompilerContext.ErrorAndThrow(new DiagMsgEx(DiagCodeEx.SchemaClassCannotBeGeneric), GetTextSpan(typeSymbol));
                                }
                                if (typeSymbol.IsStatic)
                                {
                                    CompilerContext.ErrorAndThrow(new DiagMsgEx(DiagCodeEx.SchemaClassCannotBeStatic), GetTextSpan(typeSymbol));
                                }
                                var clsName = GetFirstArgumentAsString(clsAttData);
                                if (clsName == null)
                                {
                                    CompilerContext.ErrorAndThrow(new DiagMsgEx(DiagCodeEx.InvalidSchemaClassAttribute), GetTextSpan(clsAttData));
                                }
                                var clsInfo = nsInfo.TryGetGlobalType<ClassTypeInfo>(clsName);
                                if (clsInfo == null)
                                {
                                    CompilerContext.ErrorAndThrow(new DiagMsgEx(DiagCodeEx.InvalidSchemaClassAttributeName, clsName), GetTextSpan(clsAttData));
                                }
                                if (clsInfo.Symbol != null)
                                {
                                    CompilerContext.ErrorAndThrow(new DiagMsgEx(DiagCodeEx.DuplicateSchemaClassAttributeName, clsName), GetTextSpan(clsAttData));
                                }
                                if (!clsInfo.IsAbstract)
                                {
                                    if (typeSymbol.IsAbstract)
                                    {
                                        CompilerContext.ErrorAndThrow(new DiagMsgEx(DiagCodeEx.NonAbstractSchemaClassRequired),
                                            GetTextSpan(typeSymbol));
                                    }
                                    if (!typeSymbol.HasParameterlessConstructor())
                                    {
                                        CompilerContext.ErrorAndThrow(new DiagMsgEx(DiagCodeEx.ParameterlessConstructorRequired),
                                            GetTextSpan(typeSymbol));
                                    }
                                }
                                clsInfo.Symbol = typeSymbol;
                                typeSymbolList.RemoveAt(i);
                                continue;
                            }
                            ++i;
                        }

                        foreach (var typeSymbol in typeSymbolList)
                        {
                            if (!typeSymbol.IsGenericType)
                            {
                                var clsName = typeSymbol.Name;
                                var clsInfo = nsInfo.TryGetGlobalType<ClassTypeInfo>(clsName);
                                if (clsInfo != null)
                                {
                                    if (clsInfo.Symbol == null)
                                    {
                                        if (typeSymbol.IsStatic)
                                        {
                                            CompilerContext.ErrorAndThrow(new DiagMsgEx(DiagCodeEx.SchemaClassCannotBeStatic), GetTextSpan(typeSymbol));
                                        }
                                        if (!clsInfo.IsAbstract)
                                        {
                                            if (typeSymbol.IsAbstract)
                                            {
                                                CompilerContext.ErrorAndThrow(new DiagMsgEx(DiagCodeEx.NonAbstractSchemaClassRequired),
                                                    GetTextSpan(typeSymbol));
                                            }
                                            if (!typeSymbol.HasParameterlessConstructor())
                                            {
                                                CompilerContext.ErrorAndThrow(new DiagMsgEx(DiagCodeEx.ParameterlessConstructorRequired),
                                                    GetTextSpan(typeSymbol));
                                            }
                                        }
                                        clsInfo.Symbol = typeSymbol;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            foreach (var subNsSymbol in nsSymbol.GetNamespaceMembers())
            {
                MapGlobalTypes(nsInfoMap, subNsSymbol);
            }
        }
开发者ID:knat,项目名称:SData,代码行数:97,代码来源:CSEX.cs

示例15: ScanNamespace

 private static void ScanNamespace(IList<Diagnostic> diagnostics, INamespaceSymbol namespaceSymbol)
 {
     foreach (var member in namespaceSymbol.GetNamespaceMembers())
     {
         ScanNamespace(diagnostics, member);
     }
     foreach (var member in namespaceSymbol.GetTypeMembers())
     {
         ScanType(diagnostics, member);
     }
 }
开发者ID:leloulight,项目名称:KestrelHttpServer,代码行数:11,代码来源:StandardsPoliceCompileModule.cs


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