private async Task NotifyLegacyProjectSystemAsync(
            ProjectId projectId,
            IEnumerable <DesignerAttributeData> data,
            CancellationToken cancellationToken)
        {
            // legacy project system can only be talked to on the UI thread.
            await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield : true, cancellationToken);

            cancellationToken.ThrowIfCancellationRequested();

            AssertIsForeground();

            var designerService = _legacyDesignerService ??= (IVSMDDesignerService)_serviceProvider.GetService(typeof(SVSMDDesignerService));

            if (designerService == null)
            {
                return;
            }

            var hierarchy = _workspace.GetHierarchy(projectId);

            if (hierarchy == null)
            {
                return;
            }

            foreach (var info in data)
            {
                cancellationToken.ThrowIfCancellationRequested();
                NotifyLegacyProjectSystemOnUIThread(designerService, hierarchy, info);
            }
        }
        public static bool TryGetImageListAndIndex(this VisualStudioWorkspaceImpl workspace, IVsImageService2 imageService, ProjectId id, out IntPtr imageList, out ushort index)
        {
            var hierarchy = workspace.GetHierarchy(id);

            if (hierarchy != null)
            {
                return(TryGetImageListAndIndex(hierarchy, imageService, VSConstants.VSITEMID_ROOT, out imageList, out index));
            }

            imageList = default;
            index     = 0;
            return(false);
        }
Esempio n. 3
0
        public static bool TryGetImageListAndIndex(this VisualStudioWorkspaceImpl workspace, IVsImageService2 imageService, DocumentId id, out IntPtr imageList, out ushort index)
        {
            var hierarchy = workspace.GetHierarchy(id.ProjectId);
            var document  = workspace.CurrentSolution.GetDocument(id);

            if (hierarchy != null)
            {
                var itemId = hierarchy.TryGetItemId(document.FilePath);
                return(TryGetImageListAndIndex(hierarchy, imageService, itemId, out imageList, out index));
            }

            imageList = default;
            index     = 0;
            return(false);
        }