Beispiel #1
0
        internal async Task BeginGetGraphDataAsync(IGraphContext context)
        {
            try
            {
                await InitializeAsync().ConfigureAwait(false);

                var actionHandlers     = GraphActionHandlers.Where(x => x.Value.CanHandleRequest(context));
                var shouldTrackChanges = actionHandlers.Aggregate(
                    false, (previousTrackFlag, handler) => previousTrackFlag || handler.Value.HandleRequest(context));

                lock (_expandedGraphContextsLock)
                {
                    if (shouldTrackChanges && !ExpandedGraphContexts.Contains(context))
                    {
                        // Remember this graph context in order to track changes.
                        // When references change, we will adjust children of this graph as necessary
                        ExpandedGraphContexts.Add(context);
                    }
                }
            }
            finally
            {
                // OnCompleted must be called to display changes
                context.OnCompleted();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Property ExpandedGraphContexts remembers graph expanded or checked so far.
        /// Each context represents one level in the graph, i.e. a node and its first level dependencies
        /// Tracking changes over all expanded contexts ensures that all levels are processed
        /// and updated when there are any changes in nodes data.
        /// </summary>
        internal Task TrackChangesAsync(SnapshotChangedEventArgs updatedProjectContext)
        {
            IList<IGraphContext> expandedContexts;
            lock (_expandedGraphContextsLock)
            {
                expandedContexts = ExpandedGraphContexts.ToList();
            }

            if (expandedContexts.Count == 0)
            {
                return Task.CompletedTask;
            }

            var actionHandlers = GraphActionHandlers.Where(x => x.Value.CanHandleChanges());
            if (!actionHandlers.Any())
            {
                return Task.CompletedTask;
            }

            foreach (var graphContext in expandedContexts.ToList())
            {
                try
                {
                    actionHandlers.ForEach(x => x.Value.HandleChanges(graphContext, updatedProjectContext));
                }
                finally
                {
                    // Calling OnCompleted ensures that the changes are reflected in UI
                    graphContext.OnCompleted();
                }
            }

            return Task.CompletedTask;
        }
        /// <summary>
        /// Property ExpandedGraphContexts remembers graph expanded or checked so far.
        /// Each context represents one level in the graph, i.e. a node and its first level dependencies
        /// Tracking changes over all expanded contexts ensures that all levels are processed
        /// and updated when there are any changes in nodes data.
        /// </summary>
        private void TrackChanges(SnapshotChangedEventArgs updatedProjectContext)
        {
            IList <IGraphContext> expandedContexts;

            lock (_expandedGraphContextsLock)
            {
                expandedContexts = ExpandedGraphContexts.ToList();
            }

            if (expandedContexts.Count == 0)
            {
                return;
            }

            var actionHandlers = GraphActionHandlers.Select(x => x.Value).Where(x => x.CanHandleChanges()).ToList();

            if (actionHandlers.Count == 0)
            {
                return;
            }

            foreach (IGraphContext graphContext in expandedContexts)
            {
                try
                {
                    foreach (IDependenciesGraphActionHandler actionHandler in actionHandlers)
                    {
                        actionHandler.HandleChanges(graphContext, updatedProjectContext);
                    }
                }
                finally
                {
                    // Calling OnCompleted ensures that the changes are reflected in UI
                    graphContext.OnCompleted();
                }
            }
        }
        /// <summary>
        /// Property ExpandedGraphContexts remembers graph expanded or checked so far.
        /// Each context represents one level in the graph, i.e. a node and its first level dependencies
        /// Tracking changes over all expanded contexts ensures that all levels are processed
        /// and updated when there are any changes in nodes data.
        /// </summary>
        internal Task TrackChangesAsync(SnapshotChangedEventArgs updatedProjectContext)
        {
            IList <IGraphContext> expandedContexts;

            lock (_expandedGraphContextsLock)
            {
                expandedContexts = ExpandedGraphContexts.ToList();
            }

            if (expandedContexts.Count == 0)
            {
                return(Task.CompletedTask);
            }

            IEnumerable <Lazy <IDependenciesGraphActionHandler, IOrderPrecedenceMetadataView> > actionHandlers = GraphActionHandlers.Where(x => x.Value.CanHandleChanges());

            if (!actionHandlers.Any())
            {
                return(Task.CompletedTask);
            }

            foreach (IGraphContext graphContext in expandedContexts.ToList())
            {
                try
                {
                    actionHandlers.ForEach(x => x.Value.HandleChanges(graphContext, updatedProjectContext));
                }
                finally
                {
                    // Calling OnCompleted ensures that the changes are reflected in UI
                    graphContext.OnCompleted();
                }
            }

            return(Task.CompletedTask);
        }
        internal async Task BeginGetGraphDataAsync(IGraphContext context)
        {
            try
            {
                await InitializeAsync();

                IEnumerable <Lazy <IDependenciesGraphActionHandler, IOrderPrecedenceMetadataView> > actionHandlers = GraphActionHandlers.Where(x => x.Value.CanHandleRequest(context));
                bool shouldTrackChanges = actionHandlers.Aggregate(
                    false, (previousTrackFlag, handler) => previousTrackFlag || handler.Value.HandleRequest(context));

                if (!shouldTrackChanges)
                {
                    return;
                }

                lock (_expandedGraphContextsLock)
                {
                    if (!ExpandedGraphContexts.Contains(context))
                    {
                        // Remember this graph context in order to track changes.
                        // When references change, we will adjust children of this graph as necessary
                        ExpandedGraphContexts.Add(context);
                    }
                }
            }
            finally
            {
                // OnCompleted must be called to display changes
                context.OnCompleted();
            }
        }