/// <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 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 async Task TrackChangesAsync(IDependenciesGraphProjectContext updatedProjectContext) { foreach (var graphContext in ExpandedGraphContexts.ToList()) { try { await TrackChangesOnGraphContextAsync(graphContext, updatedProjectContext).ConfigureAwait(false); } 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> 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); }