/// <summary>
        /// Converts the <see cref="IVsTextView"/> to an <see cref="IWpfTextView"/>/
        /// </summary>
        /// <returns></returns>
        internal static IWpfTextView?ToIWpfTextView(this IVsTextView nativeView)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            IVsEditorAdaptersFactoryService?editorAdapter = VS.GetMefService <IVsEditorAdaptersFactoryService>();

            return(editorAdapter?.GetWpfTextView(nativeView));
        }
        /// <summary>
        /// Converts the <see cref="IVsTextView"/> to an <see cref="IWpfTextView"/>/
        /// </summary>
        /// <returns></returns>
        public static IVsTextView?ToIVsTextView(this IWpfTextView view)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            IVsEditorAdaptersFactoryService?editorAdapter = VS.GetMefService <IVsEditorAdaptersFactoryService>();

            return(editorAdapter?.GetViewAdapter(view));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Converts a <see cref="IVsHierarchy"/> to a <see cref="IVsHierarchyItem"/>.
        /// </summary>
        public static IVsHierarchyItem ToHierarchyItem(this IVsHierarchy hierarchy, uint itemId)
        {
            if (hierarchy == null)
            {
                throw new ArgumentNullException(nameof(hierarchy));
            }

            IVsHierarchyItemManager manager = VS.GetMefService <IVsHierarchyItemManager>();

            return(manager.GetHierarchyItem(hierarchy, itemId));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Converts a <see cref="IVsHierarchy"/> to a <see cref="IVsHierarchyItem"/>.
        /// </summary>
        /// <returns>Returns <see langword="null"/> if unable to get the hierarchy item.</returns>
        public static IVsHierarchyItem?ToHierarchyItem(this IVsHierarchy hierarchy, uint itemId)
        {
            if (hierarchy == null)
            {
                return(null);
            }

            IVsHierarchyItemManager?manager = VS.GetMefService <IVsHierarchyItemManager>();

            manager.TryGetHierarchyItem(hierarchy, itemId, out IVsHierarchyItem? item);
            return(item);
        }