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


C# INamespaceOrTypeSymbol.GetMembers方法代码示例

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


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

示例1: dfs_through_members

 private void dfs_through_members(TreeNodeCollection treenode, INamespaceOrTypeSymbol symbol)
 {
     if (symbol != null && symbol.GetMembers() != null)
     foreach (var el in symbol.GetMembers()) {
         var cur = el as INamespaceOrTypeSymbol;
         if (cur != null) {
             treenode.Add(cur.Name.ToString());
             dfs_through_members(treenode[treenode.Count - 1].Nodes, cur);
         }
     }
 }
开发者ID:Emettant,项目名称:Metr2,代码行数:11,代码来源:Form1.cs

示例2: Bind

        // returns all the symbols in the container corresponding to the node
        private void Bind(int index, INamespaceOrTypeSymbol rootContainer, List<ISymbol> results, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var node = _nodes[index];

            if (_nodes[node.ParentIndex].IsRoot)
            {
                results.AddRange(rootContainer.GetMembers(node.Name));
            }
            else
            {
                using (var containerSymbols = SharedPools.Default<List<ISymbol>>().GetPooledObject())
                {
                    Bind(node.ParentIndex, rootContainer, containerSymbols.Object, cancellationToken);

                    foreach (var containerSymbol in containerSymbols.Object.OfType<INamespaceOrTypeSymbol>())
                    {
                        cancellationToken.ThrowIfCancellationRequested();

                        results.AddRange(containerSymbol.GetMembers(node.Name));
                    }
                }
            }
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:26,代码来源:SymbolTreeInfo.cs

示例3: GetAllSymbols

        IEnumerable<ISymbol> GetAllSymbols(INamespaceOrTypeSymbol root) {
            foreach(var m in root.GetMembers()) {
                yield return m;

                var r2 = m as INamespaceOrTypeSymbol;
                if(r2 != null)
                    foreach(var m2 in GetAllSymbols(r2))
                        yield return m2;
            }
        }
开发者ID:josan84,项目名称:StockSharp,代码行数:10,代码来源:VSSolution.cs

示例4: Visit

		private void Visit(INamespaceOrTypeSymbol type)
		{
			foreach (var method in type.GetMembers().OfType<IMethodSymbol>())
			{
				Visit(method);
			}
		}
开发者ID:tumtumtum,项目名称:Shaolinq,代码行数:7,代码来源:CompilationLookup.cs

示例5: GetDeclaredSymbols

        private void GetDeclaredSymbols(INamespaceOrTypeSymbol container, List<ISymbol> symbols)
        {
            foreach (var member in container.GetMembers())
            {
                symbols.Add(member);

                var nsOrType = member as INamespaceOrTypeSymbol;
                if (nsOrType != null)
                {
                    GetDeclaredSymbols(nsOrType, symbols);
                }
            }
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:13,代码来源:SymbolKeyTests.cs

示例6: Bind

        // returns all the symbols in the container corresponding to the node
        private void Bind(
            int index, INamespaceOrTypeSymbol rootContainer, ArrayBuilder<ISymbol> results, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var node = _nodes[index];
            if (node.IsRoot)
            {
                return;
            }

            if (_nodes[node.ParentIndex].IsRoot)
            {
                results.AddRange(rootContainer.GetMembers(GetName(node)));
            }
            else
            {
                var containerSymbols = ArrayBuilder<ISymbol>.GetInstance();
                try
                {
                    Bind(node.ParentIndex, rootContainer, containerSymbols, cancellationToken);

                    foreach (var containerSymbol in containerSymbols)
                    {
                        cancellationToken.ThrowIfCancellationRequested();

                        var nsOrType = containerSymbol as INamespaceOrTypeSymbol;
                        if (nsOrType != null)
                        {
                            results.AddRange(nsOrType.GetMembers(GetName(node)));
                        }
                    }
                }
                finally
                {
                    containerSymbols.Free();
                }
            }
        }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:40,代码来源:SymbolTreeInfo.cs

示例7: dfs

        private static void dfs(Solution solution, Compilation compilation,  INamespaceOrTypeSymbol v)
        {
            if (v == null) return;
            foreach (var cur in v.GetMembers())
            {
                var to = cur as INamespaceOrTypeSymbol;
                if (to != null)
                {
                    var toAsType = to as ITypeSymbol;
                    if (toAsType != null)
                    {
                        if (toAsType.BaseType != null)
                        {
                            if (!_cacheTypesHierarchy[compilation].ContainsKey(toAsType.BaseType))
                                _cacheTypesHierarchy[compilation].Add(toAsType.BaseType, new HashSet<ITypeSymbol>());

                            _cacheTypesHierarchy[compilation][toAsType.BaseType].Add(toAsType);
                        }
                    }
                    dfs(solution, compilation,  to);
                }

                var asMeth = cur as IMethodSymbol;
                //if (asMeth != null)
                //{
                //    if (asMeth.PartialImplementationPart != null)
                //        asMeth = asMeth.PartialImplementationPart; // if partial method => work with implementation

                //    var declarings = asMeth.DeclaringSyntaxReferences;
                //    if (declarings != null && declarings.Length == 1)// it is a method, so it could not be implemented in two places.
                //        foreach (var invocationExpression in
                //                 declarings
                //                 .First()
                //                 .GetSyntax()
                //                 .DescendantNodes()
                //                 .OfType<InvocationExpressionSyntax>())
                //            foreach (var model in models)
                //            {
                //                try
                //                {
                //                    //var t1 = invocationExpression.Parent;
                //                    //var t2 = invocationExpression.Parent.Parent;
                //                    //var t3 = invocationExpression.Parent.Parent.Parent;
                //                    //var t4 = invocationExpression.Parent.Parent.Parent.Parent;

                //                    SymbolInfo symbolInfo = model.GetSymbolInfo(invocationExpression);
                //                    var calledMethod = (IMethodSymbol)symbolInfo.Symbol;

                //                    if (!_cacheMethodsCoupling[compilation].ContainsKey(asMeth))
                //                        _cacheMethodsCoupling[compilation].Add(asMeth, new HashSet<ISymbol>());

                //                    _cacheMethodsCoupling[compilation][asMeth].Add(calledMethod);

                //                    break;
                //                }
                //                catch
                //                { }
                //            }

                //}

                var asPro = cur as IPropertySymbol;
                var MethodList = new List<IMethodSymbol> { asMeth };
                //we do not need analyse property, because its methods already is members to see
                //if (asPro != null) MethodList = new List<IMethodSymbol> { asPro.GetMethod, asPro.SetMethod};

                foreach (var meth in MethodList)
                {
                    if (meth != null)
                    {
                        //TODO : make it to parallel processes
                        var too = SymbolFinder.FindCallersAsync(meth, solution);
                        too.Wait();
                        var CallingMethods = new List<IMethodSymbol>();
                        foreach (var el in too.Result)
                        {
                            var method = el.CallingSymbol as IMethodSymbol;
                            if (method != null) CallingMethods.Add(method);
                            var property = el.CallingSymbol as IPropertySymbol;
                            if (property != null)
                            {
                                if (property.GetMethod != null) CallingMethods.Add(property.GetMethod);
                                if (property.SetMethod != null) CallingMethods.Add(property.SetMethod);
                            }
                        }

                        foreach (var el in CallingMethods)
                        {
                            if (el.ContainingType != meth.ContainingType)
                            {
                                if (!_cacheMethodsCoupling[compilation].ContainsKey(el))
                                    _cacheMethodsCoupling[compilation].Add(el, new HashSet<ISymbol>());

                                _cacheMethodsCoupling[compilation][el].Add(meth);
                            }
                        }

                    }
                }

//.........这里部分代码省略.........
开发者ID:Emettant,项目名称:Metr2,代码行数:101,代码来源:MetrCore.cs

示例8: Bind

        // returns all the symbols in the container corresponding to the node
        private void Bind(int index, INamespaceOrTypeSymbol rootContainer, List<ISymbol> results, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var node = this.nodes[index];

            if (this.nodes[node.ParentIndex].IsRoot)
            {
                results.AddRange(rootContainer.GetMembers(node.Name));
            }
            else
            {
                var containerSymbols = SharedPools.Default<List<ISymbol>>().AllocateAndClear();
                try
                {
                    Bind(node.ParentIndex, rootContainer, containerSymbols, cancellationToken);

                    foreach (var containerSymbol in containerSymbols.OfType<INamespaceOrTypeSymbol>())
                    {
                        cancellationToken.ThrowIfCancellationRequested();

                        results.AddRange(containerSymbol.GetMembers(node.Name));
                    }
                }
                finally
                {
                    SharedPools.Default<List<ISymbol>>().ClearAndFree(containerSymbols);
                }
            }
        }
开发者ID:riversky,项目名称:roslyn,代码行数:31,代码来源:SymbolTreeInfo.cs

示例9: dfs_through_members_build_name

 private void dfs_through_members_build_name(String name, INamespaceOrTypeSymbol symbol)
 {
     if (symbol != null && symbol.GetMembers() != null)
         foreach (var el in symbol.GetMembers())
         {
             var cur = el as INamespaceOrTypeSymbol;
             if (cur != null)
             {
                 var cur_name = name + "." + cur.Name.ToString();
                 current_names.Add(cur_name);
                 dfs_through_members_build_name(cur_name, cur);
             }
         }
 }
开发者ID:Emettant,项目名称:Metr2,代码行数:14,代码来源:MetrInterface.cs


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