コード例 #1
0
        public ValueTask <ImmutableArray <SerializableValueTrackedItem> > TrackValueSourceAsync(PinnedSolutionInfo solutionInfo, TextSpan selection, DocumentId documentId, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(solutionInfo, async solution =>
            {
                if (solution is null)
                {
                    throw new InvalidOperationException();
                }

                var document = solution.GetRequiredDocument(documentId);

                var progress = new ValueTrackingProgressCollector();
                await ValueTracker.TrackValueSourceAsync(selection, document, progress, cancellationToken).ConfigureAwait(false);

                var items = progress.GetItems();
                return items.SelectAsArray(item => SerializableValueTrackedItem.Dehydrate(solution, item, cancellationToken));
            }, cancellationToken));
        }
コード例 #2
0
        public ValueTask <ImmutableArray <SerializableValueTrackedItem> > TrackValueSourceAsync(PinnedSolutionInfo solutionInfo, SerializableValueTrackedItem previousTrackedItem, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(solutionInfo, async solution =>
            {
                if (solution is null)
                {
                    throw new InvalidOperationException();
                }

                var previousItem = await previousTrackedItem.RehydrateAsync(solution, cancellationToken).ConfigureAwait(false);
                if (previousItem is null)
                {
                    return ImmutableArray <SerializableValueTrackedItem> .Empty;
                }

                var progress = new ValueTrackingProgressCollector();
                await ValueTracker.TrackValueSourceAsync(solution, previousItem, progress, cancellationToken).ConfigureAwait(false);

                var items = progress.GetItems();
                return items.SelectAsArray(item => SerializableValueTrackedItem.Dehydrate(solution, item, cancellationToken));
            }, cancellationToken));
        }