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); }
public ActiveProjectCacheManager(IDocumentTrackingService documentTrackingService, ProjectCacheService projectCacheService) { _projectCacheService = projectCacheService; documentTrackingService.ActiveDocumentChanged += UpdateCache; UpdateCache(null, documentTrackingService.TryGetActiveDocument()); }
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) { if (workspaceServices.Workspace.Kind != WorkspaceKind.Host) { return(new ProjectCacheService(workspaceServices.Workspace)); } var service = new ProjectCacheService( workspaceServices.Workspace, ImplicitCacheTimeoutInMS ); // 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 ) { service.ClearImplicitCache(); } }; return(service); }
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 ImplicitCacheMonitor(ProjectCacheService owner, int backOffTimeSpanInMS) : base(AggregateAsynchronousOperationListener.CreateEmptyListener(), backOffTimeSpanInMS, CancellationToken.None) { _owner = owner; _gate = new SemaphoreSlim(0); Start(); }
public ActiveProjectCacheManager(IDocumentTrackingService documentTrackingService, ProjectCacheService projectCacheService) { _documentTrackingService = documentTrackingService; _projectCacheService = projectCacheService; if (documentTrackingService != null) { documentTrackingService.ActiveDocumentChanged += UpdateCache; UpdateCache(null, documentTrackingService.GetActiveDocument()); } }
private static IWorkspaceService GetMiscProjectCache(HostWorkspaceServices workspaceServices) { var projectCacheService = new ProjectCacheService(workspaceServices.Workspace, ImplicitCacheTimeoutInMS); // 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) { projectCacheService.ClearImplicitCache(); } }; return(projectCacheService); }
public Cache(ProjectCacheService cacheService, ProjectId key) { _cacheService = cacheService; _key = key; }