コード例 #1
0
        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));
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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();
                }
            };
        }
コード例 #5
0
            public void Dispose()
            {
                if (cacheService != null)
                {
                    cacheService.CacheFlushRequested -= OnCacheFlushRequested;
                    cacheService = null;
                }

                Manager?.Dispose();
                Manager = null;
            }