public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) { // we support active document tracking only for visual studio workspace host. if (workspaceServices.Workspace is MonoDevelopWorkspace monoDevelopWorkspace) { // We will finish setting this up in VisualStudioWorkspaceImpl.DeferredInitializationState var projectCacheService = new MonoDevelopProjectCacheService(monoDevelopWorkspace, ImplicitCacheTimeoutInMS); var documentTrackingService = workspaceServices.GetService <IDocumentTrackingService> (); // Subscribe to events so that we can cache items from the active document's project var manager = new ActiveProjectCacheManager(documentTrackingService, projectCacheService); projectCacheService.Manager = manager; // Subscribe to requests to clear the cache var workspaceCacheService = workspaceServices.GetService <IWorkspaceCacheService> (); projectCacheService.SubscribeToFlushRequested(workspaceCacheService); // Also clear the cache when the solution is cleared or removed. monoDevelopWorkspace.WorkspaceChanged += (s, e) => { if (e.Kind == WorkspaceChangeKind.SolutionCleared || e.Kind == WorkspaceChangeKind.SolutionRemoved) { manager.Clear(); } }; return(projectCacheService); } // TODO: Handle miscellaneous files workspace later on. return(new ProjectCacheService(workspaceServices.Workspace)); }
private static IWorkspaceService GetVisualStudioProjectCache(HostWorkspaceServices workspaceServices) { var projectCacheService = new ProjectCacheService(workspaceServices.Workspace, ImplicitCacheTimeoutInMS); var documentTrackingService = workspaceServices.GetService<IDocumentTrackingService>(); // Subscribe to events so that we can cache items from the active document's project var manager = new ActiveProjectCacheManager(documentTrackingService, projectCacheService); // Subscribe to requests to clear the cache var workspaceCacheService = workspaceServices.GetService<IWorkspaceCacheService>(); if (workspaceCacheService != null) { workspaceCacheService.CacheFlushRequested += (s, e) => manager.Clear(); } // Also clear the cache when the solution is cleared or removed. workspaceServices.Workspace.WorkspaceChanged += (s, e) => { if (e.Kind == WorkspaceChangeKind.SolutionCleared || e.Kind == WorkspaceChangeKind.SolutionRemoved) { manager.Clear(); } }; return projectCacheService; }
private static IWorkspaceService GetVisualStudioProjectCache(HostWorkspaceServices workspaceServices) { var projectCacheService = new ProjectCacheService(workspaceServices.Workspace, ImplicitCacheTimeoutInMS); var documentTrackingService = workspaceServices.GetService <IDocumentTrackingService>(); // Subscribe to events so that we can cache items from the active document's project var manager = new ActiveProjectCacheManager(documentTrackingService, projectCacheService); // Subscribe to requests to clear the cache var workspaceCacheService = workspaceServices.GetService <IWorkspaceCacheService>(); if (workspaceCacheService != null) { workspaceCacheService.CacheFlushRequested += (s, e) => manager.Clear(); } // Also clear the cache when the solution is cleared or removed. workspaceServices.Workspace.WorkspaceChanged += (s, e) => { if (e.Kind == WorkspaceChangeKind.SolutionCleared || e.Kind == WorkspaceChangeKind.SolutionRemoved) { manager.Clear(); } }; return(projectCacheService); }
internal static void ConnectProjectCacheServiceToDocumentTracking( HostWorkspaceServices workspaceServices, ProjectCacheService projectCacheService ) { var documentTrackingService = workspaceServices.GetService <IDocumentTrackingService>(); // Subscribe to events so that we can cache items from the active document's project var manager = new ActiveProjectCacheManager( documentTrackingService, projectCacheService ); // Subscribe to requests to clear the cache var workspaceCacheService = workspaceServices.GetService <IWorkspaceCacheService>(); if (workspaceCacheService != null) { workspaceCacheService.CacheFlushRequested += (s, e) => manager.Clear(); } // Also clear the cache when the solution is cleared or removed. workspaceServices.Workspace.WorkspaceChanged += (s, e) => { if ( e.Kind == WorkspaceChangeKind.SolutionCleared || e.Kind == WorkspaceChangeKind.SolutionRemoved ) { manager.Clear(); } }; }
public void Dispose() { if (cacheService != null) { cacheService.CacheFlushRequested -= OnCacheFlushRequested; cacheService = null; } Manager?.Dispose(); Manager = null; }