using System;
namespace Spectre.Console.Rendering
{
///
/// Represents a render hook scope.
///
public sealed class RenderHookScope : IDisposable
{
private readonly IAnsiConsole _console;
private readonly IRenderHook _hook;
///
/// Initializes a new instance of the class.
///
/// The console to attach the render hook to.
/// The render hook.
public RenderHookScope(IAnsiConsole console, IRenderHook hook)
{
_console = console ?? throw new ArgumentNullException(nameof(console));
_hook = hook ?? throw new ArgumentNullException(nameof(hook));
_console.Pipeline.Attach(_hook);
}
///
public void Dispose()
{
_console.Pipeline.Detach(_hook);
}
}
}