using System; using Spectre.Console.Composition; using Spectre.Console.Internal; namespace Spectre.Console { /// /// Contains extension methods for . /// public static partial class ConsoleExtensions { /// /// Renders the specified object to the console. /// /// The console to render to. /// The object to render. public static void Render(this IAnsiConsole console, IRenderable renderable) { if (console is null) { throw new ArgumentNullException(nameof(console)); } if (renderable is null) { throw new ArgumentNullException(nameof(renderable)); } foreach (var segment in renderable.Render(console.Encoding, console.Width)) { if (!segment.Style.Equals(Style.Plain)) { using (var style = console.PushStyle(segment.Style)) { console.Write(segment.Text); } } else { console.Write(segment.Text); } } } } }