Moved VisualStudioInfoBarService, exported as workspace service

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