コード例 #1
0
        protected void InitializeStandardVisualStudioWorkspace(SVsServiceProvider serviceProvider, SaveEventsService saveEventsService)
        {
            var projectTracker = new VisualStudioProjectTracker(serviceProvider);

            // Ensure the document tracking service is initialized on the UI thread
            var documentTrackingService = this.Services.GetService <IDocumentTrackingService>();
            var documentProvider        = new RoslynDocumentProvider(projectTracker, serviceProvider, documentTrackingService);

            projectTracker.DocumentProvider = documentProvider;

            projectTracker.MetadataReferenceProvider = this.Services.GetService <VisualStudioMetadataReferenceManager>();
            projectTracker.RuleSetFileProvider       = this.Services.GetService <VisualStudioRuleSetManager>();

            this.SetProjectTracker(projectTracker);

            var workspaceHost = new VisualStudioWorkspaceHost(this);

            projectTracker.RegisterWorkspaceHost(workspaceHost);
            projectTracker.StartSendingEventsToWorkspaceHost(workspaceHost);

            saveEventsService.StartSendingSaveEvents();

            // Ensure the options factory services are initialized on the UI thread
            this.Services.GetService <IOptionService>();
        }
コード例 #2
0
            public DeferredInitializationState(VisualStudioWorkspaceImpl workspace, IServiceProvider serviceProvider)
                : base(assertIsForeground: true)
            {
                ServiceProvider          = serviceProvider;
                ShellOpenDocumentService = (IVsUIShellOpenDocument)serviceProvider.GetService(typeof(SVsUIShellOpenDocument));
                ProjectTracker           = new VisualStudioProjectTracker(serviceProvider, workspace.Services);

                // Ensure the document tracking service is initialized on the UI thread
                var documentTrackingService   = (VisualStudioDocumentTrackingService)workspace.Services.GetService <IDocumentTrackingService>();
                var documentProvider          = new DocumentProvider(ProjectTracker, serviceProvider, documentTrackingService);
                var metadataReferenceProvider = workspace.Services.GetService <VisualStudioMetadataReferenceManager>();
                var ruleSetFileProvider       = workspace.Services.GetService <VisualStudioRuleSetManager>();

                ProjectTracker.InitializeProviders(documentProvider, metadataReferenceProvider, ruleSetFileProvider);

                var workspaceHost = new VisualStudioWorkspaceHost(workspace);

                ProjectTracker.RegisterWorkspaceHost(workspaceHost);
                ProjectTracker.StartSendingEventsToWorkspaceHost(workspaceHost);

                var componentModel    = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
                var saveEventsService = componentModel.GetService <SaveEventsService>();

                saveEventsService.StartSendingSaveEvents();

                VisualStudioProjectCacheHostServiceFactory.ConnectProjectCacheServiceToDocumentTracking(workspace.Services, (ProjectCacheService)workspace.CurrentSolution.Services.CacheService);

                // Ensure the options factory services are initialized on the UI thread
                workspace.Services.GetService <IOptionService>();
            }