private void SolutionManager_CacheUpdated(object sender, NuGetEventArgs <string> e) { if (Model.IsSolution) { // This means that the UI is open for the solution. Refresh(); } else { // This is a project package manager, so there is one and only one project. var project = Model.Context.Projects.First(); string projectFullName; var projectContainsFullPath = project.TryGetMetadata(NuGetProjectMetadataKeys.FullPath, out projectFullName); var eventProjectFullName = e.Arg; // This ensures that we refresh the UI only if the event.project.FullName matches the NuGetProject.FullName. // We also refresh the UI if projectFullPath is not present. if (!projectContainsFullPath || projectFullName == eventProjectFullName) { Refresh(); } } }
private void Console_ExecuteInputLine(object sender, NuGetEventArgs <Tuple <SnapshotSpan, bool> > e) { // Don't add empty spans (e.g. executed "cls") SnapshotSpan snapshotSpan = e.Arg.Item1.TranslateTo(Console.WpfTextView.TextSnapshot, SpanTrackingMode.EdgePositive); if (!snapshotSpan.IsEmpty) { _commandLineSpans.Add(snapshotSpan, e.Arg.Item2); } }
private void Console_NewColorSpan(object sender, NuGetEventArgs <Tuple <SnapshotSpan, Color?, Color?> > e) { // At least one of foreground or background must be specified, otherwise we don't care. if (e.Arg.Item2 != null || e.Arg.Item3 != null) { _colorSpans.Add(Tuple.Create( e.Arg.Item1.Span, TextFormatClassifier.GetClassificationType(e.Arg.Item2, e.Arg.Item3))); ClassificationChanged.Raise(this, new ClassificationChangedEventArgs(e.Arg.Item1)); } }
private async Task FireNuGetCacheUpdatedEventAsync(NuGetEventArgs <string> e) { try { // Await a delay of 100 mSec to batch multiple cache updated events. // This ensures the minimum duration between 2 consecutive UI refresh, caused by cache update, to be 100 mSec. await Task.Delay(100); // Check if the cache is still dirty if (_projectSystemCache.TestResetDirtyFlag()) { // Fire the event only if the cache is dirty AfterNuGetCacheUpdated?.Invoke(this, e); } } catch (Exception ex) { _logger.LogError(ex.ToString()); } }
/// <summary> /// This method is invoked when ProjectSystemCache fires a CacheUpdated event. /// This method inturn invokes AfterNuGetCacheUpdated event which is consumed by PackageManagerControl.xaml.cs /// </summary> /// <param name="sender">Event sender object</param> /// <param name="e">Event arguments. This will be EventArgs.Empty</param> private void NuGetCacheUpdate_After(object sender, NuGetEventArgs <string> e) { // The AfterNuGetCacheUpdated event is raised on a separate Task to prevent blocking of the caller. // E.g. - If Restore updates the cache entries on CPS nomination, then restore should not be blocked till UI is restored. NuGetUIThreadHelper.JoinableTaskFactory.RunAsync(() => FireNuGetCacheUpdatedEventAsync(e)); }
private void OnAfterNuGetCacheUpdated(object sender, NuGetEventArgs <string> e) { AfterNuGetCacheUpdated?.Invoke(sender, e.Arg); }