Moved VisualStudioInfoBarService, exported as workspace service

上级 e9053e6b
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
using System.ComponentModel.Composition; using System.ComponentModel.Composition;
using System.Linq; using System.Linq;
using Microsoft.CodeAnalysis.Editor; using Microsoft.CodeAnalysis.Editor;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Extensions; using Microsoft.CodeAnalysis.Extensions;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.VisualStudio.Imaging; using Microsoft.VisualStudio.Imaging;
using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell;
...@@ -14,8 +16,8 @@ ...@@ -14,8 +16,8 @@
namespace Microsoft.VisualStudio.LanguageServices.Implementation namespace Microsoft.VisualStudio.LanguageServices.Implementation
{ {
[Export(typeof(IInfoBarService))] [ExportWorkspaceService(typeof(IInfoBarService))]
internal class VisualStudioInfoBarService : IInfoBarService internal class VisualStudioInfoBarService : ForegroundThreadAffinitizedObject, IInfoBarService
{ {
private readonly IServiceProvider _serviceProvider; private readonly IServiceProvider _serviceProvider;
private readonly IForegroundNotificationService _foregroundNotificationService; private readonly IForegroundNotificationService _foregroundNotificationService;
...@@ -33,11 +35,13 @@ internal class VisualStudioInfoBarService : IInfoBarService ...@@ -33,11 +35,13 @@ internal class VisualStudioInfoBarService : IInfoBarService
public void ShowInfoBarInActiveView(string message, params InfoBarUI[] items) public void ShowInfoBarInActiveView(string message, params InfoBarUI[] items)
{ {
ThisCanBeCalledOnAnyThread();
ShowInfoBar(activeView: true, message: message, items: items); ShowInfoBar(activeView: true, message: message, items: items);
} }
public void ShowInfoBarInGlobalView(string message, params InfoBarUI[] items) public void ShowInfoBarInGlobalView(string message, params InfoBarUI[] items)
{ {
ThisCanBeCalledOnAnyThread();
ShowInfoBar(activeView: false, message: message, items: items); ShowInfoBar(activeView: false, message: message, items: items);
} }
...@@ -55,6 +59,8 @@ private void ShowInfoBar(bool activeView, string message, params InfoBarUI[] ite ...@@ -55,6 +59,8 @@ private void ShowInfoBar(bool activeView, string message, params InfoBarUI[] ite
private bool TryGetInfoBarData(bool activeView, out IVsInfoBarHost infoBarHost) private bool TryGetInfoBarData(bool activeView, out IVsInfoBarHost infoBarHost)
{ {
AssertIsForeground();
infoBarHost = null; infoBarHost = null;
if (activeView) if (activeView)
......
...@@ -10,16 +10,19 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation ...@@ -10,16 +10,19 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation
[ExportWorkspaceServiceFactory(typeof(IErrorReportingService), ServiceLayer.Host), Shared] [ExportWorkspaceServiceFactory(typeof(IErrorReportingService), ServiceLayer.Host), Shared]
internal sealed class VisualStudioErrorReportingServiceFactory : IWorkspaceServiceFactory internal sealed class VisualStudioErrorReportingServiceFactory : IWorkspaceServiceFactory
{ {
private readonly IErrorReportingService _singleton; private IErrorReportingService _singleton;
[ImportingConstructor] [ImportingConstructor]
public VisualStudioErrorReportingServiceFactory(IInfoBarService infoBarService) public VisualStudioErrorReportingServiceFactory()
{ {
_singleton = new VisualStudioErrorReportingService(infoBarService);
} }
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices)
{ {
if (_singleton == null)
{
_singleton = new VisualStudioErrorReportingService(workspaceServices.GetRequiredService<IInfoBarService>());
}
return _singleton; return _singleton;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册