/// <summary>
        /// Handles opening the file associated with the given <paramref name="node"/>.
        /// </summary>
        /// <param name="node"></param>
        private void OpenFile(WorkspaceVisualNodeBase node)
        {
            if (node == null ||
                string.IsNullOrEmpty(node.NodeMoniker))
            {
                return;
            }

            _taskContext.Factory.RunAsync(async() =>
            {
                IBrokeredServiceContainer serviceContainer        = _serviceProvider.GetService <SVsBrokeredServiceContainer, IBrokeredServiceContainer>();
                ServiceHub.Framework.IServiceBroker serviceBroker = serviceContainer.GetFullAccessServiceBroker();

                IOpenDocumentService?openDocumentService = await serviceBroker.GetProxyAsync <IOpenDocumentService>(VisualStudioServices.VS2019_4.OpenDocumentService);

                try
                {
                    if (openDocumentService != null &&
                        node is IFileSystemNode fileSystemNode)
                    {
                        await openDocumentService.OpenDocumentAsync(fileSystemNode.FullPath, cancellationToken: default);
                    }
                    //else
                    // TODO: figure out what to tell the user if we can't get the service
                    // https://github.com/dotnet/project-system/issues/6306
                }
                finally
                {
                    (openDocumentService as IDisposable)?.Dispose();
                }
            });
        }
示例#2
0
        /// <summary>
        /// Handles opening the file associated with the given <paramref name="node"/>.
        /// </summary>
        /// <param name="node"></param>
        private void OpenFile(WorkspaceVisualNodeBase node)
        {
            if (node == null ||
                string.IsNullOrEmpty(node.NodeMoniker))
            {
                return;
            }

            _taskContext.Factory.RunAsync(async() =>
            {
                IBrokeredServiceContainer serviceContainer        = _serviceProvider.GetService <SVsBrokeredServiceContainer, IBrokeredServiceContainer>();
                ServiceHub.Framework.IServiceBroker serviceBroker = serviceContainer.GetFullAccessServiceBroker();

                IOpenDocumentService?openDocumentService = await serviceBroker.GetProxyAsync <IOpenDocumentService>(VisualStudioServices.VS2019_4.OpenDocumentService);

                try
                {
                    Assumes.NotNull(openDocumentService);

                    await openDocumentService.OpenDocumentAsync(node.NodeMoniker, cancellationToken: default);
                }
                finally
                {
                    (openDocumentService as IDisposable)?.Dispose();
                }
            });
        }