Succeeded() публичный статический Метод

public static Succeeded ( int hr ) : bool
hr int
Результат bool
Пример #1
0
        private bool TryFierOnAddReference(uint currentItem)
        {
            if (ReferenceAdded == null)
            {
                return(false);
            }

            int    hr2;
            object obj;

            hr2 = Hierarchy.GetProperty(currentItem, (int)__VSHPROPID.VSHPROPID_ExtObject, out obj);

            if (!ErrorHelper.Succeeded(hr2))
            {
                return(false);
            }

            var reference   = obj as VSLangProj.Reference;
            var projectItem = obj as EnvDTE.ProjectItem;

            if (reference == null && projectItem != null)
            {
                reference = projectItem.Object as VSLangProj.Reference;
            }

            if (reference != null)
            {
                ReferenceAdded(this, new ReferenceEventArgs(Hierarchy, currentItem, reference));
                return(true);
            }

            return(false);
        }
Пример #2
0
        public static IVsHierarchy GetHierarchyFromVsWindowFrame(this IVsWindowFrame frame)
        {
            object objHier;

            if (ErrorHelper.Succeeded(frame.GetProperty((int)__VSFPROPID.VSFPROPID_Hierarchy, out objHier)))
            {
                var vsHierarchy = (IVsHierarchy)objHier;
                return(vsHierarchy);
            }

            return(null);
        }
Пример #3
0
        public static T GetProp <T>(IVsHierarchy hierarchy, uint currentItem, int prop)
        {
            object obj;

            ThreadHelper.ThrowIfNotOnUIThread();

            if (ErrorHelper.Succeeded(hierarchy.GetProperty(currentItem, prop, out obj)))
            {
                return((T)obj);
            }

            return(default(T));
        }
Пример #4
0
        public static bool Navigate(this IServiceProvider serviceProvider, string path, int line, int column)
        {
            Guid logicalView = VSConstants.LOGVIEWID_TextView;

            if (VsShellUtilities.ShellIsShuttingDown)
            {
                return(false);
            }

            var vsUIShellOpenDocument = (IVsUIShellOpenDocument)serviceProvider.GetService(typeof(IVsUIShellOpenDocument));

            if (vsUIShellOpenDocument == null)
            {
                return(false);
            }

            Guid guid = logicalView;

            Microsoft.VisualStudio.OLE.Interop.IServiceProvider serviceProviderRet;
            IVsUIHierarchy vsUIHierarchy;
            uint           pItemId;
            IVsWindowFrame vsWindowFrame;

            if (ErrorHelper.Failed(vsUIShellOpenDocument.OpenDocumentViaProject(path, ref guid, out serviceProviderRet, out vsUIHierarchy, out pItemId, out vsWindowFrame)) || vsWindowFrame == null)
            {
                return(false);
            }

            object obj;

            vsWindowFrame.GetProperty(-4004, out obj);
            var vsTextBuffer = obj as VsTextBuffer;

            if (vsTextBuffer == null)
            {
                IVsTextBufferProvider vsTextBufferProvider = obj as IVsTextBufferProvider;
                if (vsTextBufferProvider != null)
                {
                    IVsTextLines vsTextLines;
                    ErrorHelper.ThrowOnFailure(vsTextBufferProvider.GetTextBuffer(out vsTextLines));
                    vsTextBuffer = vsTextLines as VsTextBuffer;
                    if (vsTextBuffer == null)
                    {
                        return(false);
                    }
                }
            }

            var vsTextManager = (IVsTextManager)serviceProvider.GetService(typeof(VsTextManagerClass));

            if (vsTextManager == null)
            {
                return(false);
            }

            if (column > 0)
            {
                column--;
            }

            if (line > 0)
            {
                line--;
            }

            return(ErrorHelper.Succeeded(vsTextManager.NavigateToLineAndColumn(vsTextBuffer, ref logicalView, line, column, line, column)));
        }