Created
August 31, 2012 09:23
-
-
Save sharwell/3550725 to your computer and use it in GitHub Desktop.
MEF support for the Output Window in Visual Studio 2010: VsOutputWindowPaneAdapter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace JavaLanguageService.Panes | |
{ | |
using System; | |
using System.Diagnostics.Contracts; | |
using Microsoft.VisualStudio; | |
using Microsoft.VisualStudio.Shell.Interop; | |
internal sealed class VsOutputWindowPaneAdapter : IOutputWindowPane, IDisposable | |
{ | |
private IVsOutputWindowPane _pane; | |
public VsOutputWindowPaneAdapter(IVsOutputWindowPane pane) | |
{ | |
Contract.Requires<ArgumentNullException>(pane != null); | |
this._pane = pane; | |
} | |
public string Name | |
{ | |
get | |
{ | |
string name = null; | |
ErrorHandler.ThrowOnFailure(this._pane.GetName(ref name)); | |
return name; | |
} | |
set | |
{ | |
ErrorHandler.ThrowOnFailure(this._pane.SetName(value)); | |
} | |
} | |
public void Dispose() | |
{ | |
_pane = null; | |
} | |
public void Activate() | |
{ | |
ErrorHandler.ThrowOnFailure(this._pane.Activate()); | |
} | |
public void Hide() | |
{ | |
ErrorHandler.ThrowOnFailure(this._pane.Hide()); | |
} | |
public void Write(string text) | |
{ | |
Contract.Requires<ArgumentNullException>(text != null); | |
ErrorHandler.ThrowOnFailure(this._pane.OutputStringThreadSafe(text)); | |
} | |
public void WriteLine(string text) | |
{ | |
Contract.Requires<ArgumentNullException>(text != null); | |
if (!text.EndsWith(Environment.NewLine)) | |
text += Environment.NewLine; | |
Write(text); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment