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


C# IImmutableSet.Contains方法代码示例

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


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

示例1: FindDocumentsAsync

        protected async Task<ImmutableArray<Document>> FindDocumentsAsync(Project project, IImmutableSet<Document> scope, Func<Document, CancellationToken, Task<bool>> predicateAsync, CancellationToken cancellationToken)
        {
            // special case for HR
            if (scope != null && scope.Count == 1)
            {
                var document = scope.First();
                if (document.Project == project)
                {
                    return scope.ToImmutableArray();
                }

                return ImmutableArray<Document>.Empty;
            }

            var documents = ArrayBuilder<Document>.GetInstance();
            foreach (var document in project.Documents)
            {
                if (scope != null && !scope.Contains(document))
                {
                    continue;
                }

                if (await predicateAsync(document, cancellationToken).ConfigureAwait(false))
                {
                    documents.Add(document);
                }
            }

            return documents.ToImmutableAndFree();
        }
开发者ID:tralivali1234,项目名称:roslyn,代码行数:30,代码来源:AbstractReferenceFinder.cs

示例2: BuildUp

		public override IEnumerable<SlideBlock> BuildUp(BuildUpContext context, IImmutableSet<string> filesInProgress)
		{
			if (filesInProgress.Contains(File))
				throw new Exception("Cyclic dependency");

			var xmlStream = new StringReader(context.FileSystem.GetContent(File));
			var serializer = new XmlSerializer(typeof(SlideBlock[]));
			var slideBlocks = (SlideBlock[])serializer.Deserialize(xmlStream);
			var newInProgress = filesInProgress.Add(File);
			return slideBlocks.SelectMany(b => b.BuildUp(context, newInProgress));
		}
开发者ID:andgein,项目名称:uLearn,代码行数:11,代码来源:IncludeBlocksBlock.cs

示例3: SearchWorkerAsync

        protected override async Task SearchWorkerAsync(ISymbol symbol, Project project, ICallHierarchySearchCallback callback, IImmutableSet<Document> documents, CancellationToken cancellationToken)
        {
            var implementations = await SymbolFinder.FindImplementationsAsync(symbol, project.Solution, cancellationToken: cancellationToken).ConfigureAwait(false);

            foreach (var implementation in implementations)
            {
                var sourceLocations = implementation.DeclaringSyntaxReferences.Select(d => project.Solution.GetDocument(d.SyntaxTree)).WhereNotNull();
                var bestLocation = sourceLocations.FirstOrDefault(d => documents == null || documents.Contains(d));
                if (bestLocation != null)
                {
                    var item = await Provider.CreateItem(implementation, bestLocation.Project, SpecializedCollections.EmptyEnumerable<Location>(), cancellationToken).ConfigureAwait(false);
                    callback.AddResult(item);
                    cancellationToken.ThrowIfCancellationRequested();
                }
            }
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:16,代码来源:ImplementerFinder.cs

示例4: CreateSpansAsync

        private async Task<IEnumerable<DocumentHighlights>> CreateSpansAsync(
            Solution solution,
            ISymbol symbol,
            IEnumerable<ReferencedSymbol> references,
            IEnumerable<Location> additionalReferences,
            IImmutableSet<Document> documentToSearch,
            CancellationToken cancellationToken)
        {
            var spanSet = new HashSet<ValueTuple<Document, TextSpan>>();
            var tagMap = new MultiDictionary<Document, HighlightSpan>();
            bool addAllDefinitions = true;

            // Add definitions
            // Filter out definitions that cannot be highlighted. e.g: alias symbols defined via project property pages.
            if (symbol.Kind == SymbolKind.Alias &&
                symbol.Locations.Length > 0)
            {
                addAllDefinitions = false;

                if (symbol.Locations.First().IsInSource)
                {
                    // For alias symbol we want to get the tag only for the alias definition, not the target symbol's definition.
                    await AddLocationSpan(symbol.Locations.First(), solution, spanSet, tagMap, HighlightSpanKind.Definition, cancellationToken).ConfigureAwait(false);
                }
            }

            // Add references and definitions
            foreach (var reference in references)
            {
                if (addAllDefinitions && ShouldIncludeDefinition(reference.Definition))
                {
                    foreach (var location in reference.Definition.Locations)
                    {
                        if (location.IsInSource)
                        {
                            var document = solution.GetDocument(location.SourceTree);

                            // GetDocument will return null for locations in #load'ed trees.
                            // TODO:  Remove this check and add logic to fetch the #load'ed tree's
                            // Document once https://github.com/dotnet/roslyn/issues/5260 is fixed.
                            if (document == null)
                            {
                                Debug.Assert(solution.Workspace.Kind == "Interactive");
                                continue;
                            }

                            if (documentToSearch.Contains(document))
                            {
                                await AddLocationSpan(location, solution, spanSet, tagMap, HighlightSpanKind.Definition, cancellationToken).ConfigureAwait(false);
                            }
                        }
                    }
                }

                foreach (var referenceLocation in reference.Locations)
                {
                    var referenceKind = referenceLocation.IsWrittenTo ? HighlightSpanKind.WrittenReference : HighlightSpanKind.Reference;
                    await AddLocationSpan(referenceLocation.Location, solution, spanSet, tagMap, referenceKind, cancellationToken).ConfigureAwait(false);
                }
            }

            // Add additional references
            foreach (var location in additionalReferences)
            {
                await AddLocationSpan(location, solution, spanSet, tagMap, HighlightSpanKind.Reference, cancellationToken).ConfigureAwait(false);
            }

            var list = new List<DocumentHighlights>(tagMap.Count);
            foreach (var kvp in tagMap)
            {
                var spans = new List<HighlightSpan>(kvp.Value.Count);
                foreach (var span in kvp.Value)
                {
                    spans.Add(span);
                }

                list.Add(new DocumentHighlights(kvp.Key, spans));
            }

            return list;
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:81,代码来源:AbstractDocumentHighlightsService.cs

示例5: CreateSpansAsync

        private async Task<IEnumerable<DocumentHighlights>> CreateSpansAsync(
            Solution solution,
            ISymbol symbol,
            IEnumerable<ReferencedSymbol> references,
            IEnumerable<Location> additionalReferences,
            IImmutableSet<Document> documentToSearch,
            CancellationToken cancellationToken)
        {
            var spanSet = new HashSet<ValueTuple<Document, TextSpan>>();
            var tagMap = new MultiDictionary<Document, HighlightSpan>();
            bool addAllDefinitions = true;

            // Add definitions
            if (symbol.Kind == SymbolKind.Alias &&
                symbol.Locations.Length > 0)
            {
                // For alias symbol we want to get the tag only for the alias definition, not the target symbol's definition.
                await AddLocationSpan(symbol.Locations.First(), solution, spanSet, tagMap, true, cancellationToken).ConfigureAwait(false);
                addAllDefinitions = false;
            }

            // Add references and definitions
            foreach (var reference in references)
            {
                if (addAllDefinitions && ShouldIncludeDefinition(reference.Definition))
                {
                    foreach (var location in reference.Definition.Locations)
                    {
                        if (location.IsInSource && documentToSearch.Contains(solution.GetDocument(location.SourceTree)))
                        {
                            await AddLocationSpan(location, solution, spanSet, tagMap, true, cancellationToken).ConfigureAwait(false);
                        }
                    }
                }

                foreach (var referenceLocation in reference.Locations)
                {
                    await AddLocationSpan(referenceLocation.Location, solution, spanSet, tagMap, false, cancellationToken).ConfigureAwait(false);
                }
            }

            // Add additional references
            foreach (var location in additionalReferences)
            {
                await AddLocationSpan(location, solution, spanSet, tagMap, false, cancellationToken).ConfigureAwait(false);
            }

            var list = new List<DocumentHighlights>(tagMap.Count);
            foreach (var kvp in tagMap)
            {
                var spans = new List<HighlightSpan>(kvp.Value.Count);
                foreach (var span in kvp.Value)
                {
                    spans.Add(span);
                }

                list.Add(new DocumentHighlights(kvp.Key, spans));
            }

            return list;
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:61,代码来源:AbstractDocumentHighlightsService.cs

示例6: ExcludePrivateFieldsBasedOnReferences

        private static void ExcludePrivateFieldsBasedOnReferences(
            IImmutableDictionary<ISymbol, PrivateField> privateFields,
            IDictionary<ISymbol, IDictionary<SyntaxNode, ISymbol>> referencesByEnclosingSymbol,
            IImmutableSet<ISymbol> classMethods)
        {
            var referencedAtLeastOnceFromClassMethod = new HashSet<ISymbol>();

            foreach (var references in referencesByEnclosingSymbol)
            {
                if (!classMethods.Contains(references.Key))
                {
                    foreach (var reference in references.Value)
                    {
                        privateFields[reference.Value].Excluded = true;
                    }

                    continue;
                }

                foreach (var reference in references.Value)
                {
                    referencedAtLeastOnceFromClassMethod.Add(reference.Value);

                    if (!IsReferenceToSingleFieldValue(reference))
                    {
                        privateFields[reference.Value].Excluded = true;
                    }
                }
            }

            foreach (var privateField in privateFields.Values)
            {
                if (!referencedAtLeastOnceFromClassMethod.Contains(privateField.Symbol))
                {
                    privateField.Excluded = true;
                }
            }
        }
开发者ID:dbolkensteyn,项目名称:sonarlint-vs,代码行数:38,代码来源:PrivateFieldUsedAsLocalVariable.cs


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