Files
spectre.console/src/Spectre.Console/Extensions/RecorderExtensions.cs
Patrik Svensson 52c1d9122b Add global usings (#668)
* Use global usings

* Fix namespace declarations for test projects
2021-12-23 16:50:31 +01:00

40 lines
1.1 KiB
C#

namespace Spectre.Console;
/// <summary>
/// Contains extension methods for <see cref="Recorder"/>.
/// </summary>
public static class RecorderExtensions
{
private static readonly TextEncoder _textEncoder = new TextEncoder();
private static readonly HtmlEncoder _htmlEncoder = new HtmlEncoder();
/// <summary>
/// Exports the recorded content as text.
/// </summary>
/// <param name="recorder">The recorder.</param>
/// <returns>The recorded content as text.</returns>
public static string ExportText(this Recorder recorder)
{
if (recorder is null)
{
throw new ArgumentNullException(nameof(recorder));
}
return recorder.Export(_textEncoder);
}
/// <summary>
/// Exports the recorded content as HTML.
/// </summary>
/// <param name="recorder">The recorder.</param>
/// <returns>The recorded content as HTML.</returns>
public static string ExportHtml(this Recorder recorder)
{
if (recorder is null)
{
throw new ArgumentNullException(nameof(recorder));
}
return recorder.Export(_htmlEncoder);
}
}