public static ThrowOnFailure ( int hr ) : int | ||
hr | int | |
Результат | int |
public static IVsTextLines GetBuffer(this IVsTextView textViewAdapter) { IVsTextLines vsTextLines; ErrorHelper.ThrowOnFailure(textViewAdapter.GetBuffer(out vsTextLines)); return(vsTextLines); }
private static string GetFilePath(IPersistFileFormat persistFileFormat) { string filePath; uint formatIndex; ErrorHelper.ThrowOnFailure(persistFileFormat.GetCurFile(out filePath, out formatIndex)); return(filePath); }
public void Dispose() { ThreadHelper.ThrowIfNotOnUIThread(); _runningDocTableEvents.OnDocumentWindowOnScreenChanged(this, false); var windowFrame2 = (IVsWindowFrame2)WindowFrame; ErrorHelper.ThrowOnFailure(windowFrame2.Unadvise(_cookie)); }
public WindowFrameInfo(IVsWindowFrame windowFrame, RunningDocTableEvents runningDocTableEvents) { ErrorHelper.ThrowIsNull(windowFrame, nameof(windowFrame)); ThreadHelper.ThrowIfNotOnUIThread(); _runningDocTableEvents = runningDocTableEvents; OnScreen = true; WindowFrame = windowFrame; #pragma warning disable VSSDK002 // Visual Studio service should be used on main thread explicitly. var windowFrame2 = (IVsWindowFrame2)windowFrame; ErrorHelper.ThrowOnFailure(windowFrame2.Advise(this, out _cookie)); #pragma warning restore VSSDK002 // Visual Studio service should be used on main thread explicitly. _runningDocTableEvents.OnDocumentWindowOnScreenChanged(this, true); }
public static IWpfTextView ToIWpfTextView(this IVsTextView vsTextView) { object obj2; IVsUserData data = vsTextView as IVsUserData; if (data == null) { return(null); } Guid guidIWpfTextViewHost = GuidIWpfTextViewHost; ErrorHelper.ThrowOnFailure(data.GetData(ref guidIWpfTextViewHost, out obj2)); IWpfTextViewHost host = obj2 as IWpfTextViewHost; return(host.TextView); }
public static ITextView ToITextView(this IVsTextView vsTextView) { object obj2; IVsUserData data = vsTextView as IVsUserData; if (data == null) { throw new InvalidOperationException("The IVsTextView shims should allow us to cast to IVsUserData"); } Guid guidIWpfTextViewHost = GuidIWpfTextViewHost; ErrorHelper.ThrowOnFailure(data.GetData(ref guidIWpfTextViewHost, out obj2)); IWpfTextViewHost host = obj2 as IWpfTextViewHost; return(host.TextView); }
public static ITextBuffer ToITextBuffer(this IVsTextBuffer vsTextBuffer) { object obj2; IVsUserData data = vsTextBuffer as IVsUserData; if (data == null) { throw new InvalidOperationException("The shims should allow us to cast to IVsUserData"); } Guid guidIVxTextBuffer = GuidIVxTextBuffer; ErrorHelper.ThrowOnFailure(data.GetData(ref guidIVxTextBuffer, out obj2)); ITextBuffer buffer = obj2 as ITextBuffer; if (buffer == null) { throw new InvalidOperationException("user data doesnt implement the interface"); } return(buffer); }
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))); }