RemoteHostClientFactory.cs 1.3 KB
Newer Older
1 2 3 4 5 6
// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

using System.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
7
using Microsoft.CodeAnalysis.Remote;
8 9
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.VisualStudio.LanguageServices.Remote;
10
using Roslyn.Test.Utilities.Remote;
11 12 13 14 15 16

namespace Roslyn.VisualStudio.DiagnosticsWindow.Remote
{
    [ExportWorkspaceService(typeof(IRemoteHostClientFactory), layer: ServiceLayer.Host), Shared]
    internal class RemoteHostClientFactory : IRemoteHostClientFactory
    {
17 18 19 20 21
        [ImportingConstructor]
        public RemoteHostClientFactory()
        {
        }

22
        public Task<RemoteHostClient> CreateAsync(Workspace workspace, CancellationToken cancellationToken)
23
        {
24 25
            // this is the point where we can create different kind of remote host client in future (cloud or etc)
            if (workspace.Options.GetOption(RemoteHostClientFactoryOptions.RemoteHost_InProc))
26
            {
C
Fix  
Cyrus Najmabadi 已提交
27
                return InProcRemoteHostClient.CreateAsync(workspace, runCacheCleanup: true);
28
            }
29

30
            return ServiceHubRemoteHostClient.CreateAsync(workspace, cancellationToken);
31 32
        }
    }
S
Sam Harwell 已提交
33
}