mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-12-30 04:15:49 +08:00
Use file scoped namespace declarations
This commit is contained in:
committed by
Phil Scott
parent
1dbaf50935
commit
ec1188b837
@@ -2,46 +2,45 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using Spectre.Console.Rendering;
|
||||
|
||||
namespace Spectre.Console
|
||||
namespace Spectre.Console;
|
||||
|
||||
/// <summary>
|
||||
/// Contains extension methods for <see cref="IRenderable"/>.
|
||||
/// </summary>
|
||||
public static class RenderableExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains extension methods for <see cref="IRenderable"/>.
|
||||
/// Gets the segments for a renderable using the specified console.
|
||||
/// </summary>
|
||||
public static class RenderableExtensions
|
||||
/// <param name="renderable">The renderable.</param>
|
||||
/// <param name="console">The console.</param>
|
||||
/// <returns>An enumerable containing segments representing the specified <see cref="IRenderable"/>.</returns>
|
||||
public static IEnumerable<Segment> GetSegments(this IRenderable renderable, IAnsiConsole console)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the segments for a renderable using the specified console.
|
||||
/// </summary>
|
||||
/// <param name="renderable">The renderable.</param>
|
||||
/// <param name="console">The console.</param>
|
||||
/// <returns>An enumerable containing segments representing the specified <see cref="IRenderable"/>.</returns>
|
||||
public static IEnumerable<Segment> GetSegments(this IRenderable renderable, IAnsiConsole console)
|
||||
if (console is null)
|
||||
{
|
||||
if (console is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(console));
|
||||
}
|
||||
|
||||
if (renderable is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(renderable));
|
||||
}
|
||||
|
||||
var context = new RenderContext(console.Profile.Capabilities);
|
||||
var renderables = console.Pipeline.Process(context, new[] { renderable });
|
||||
|
||||
return GetSegments(console, context, renderables);
|
||||
throw new ArgumentNullException(nameof(console));
|
||||
}
|
||||
|
||||
private static IEnumerable<Segment> GetSegments(IAnsiConsole console, RenderContext options, IEnumerable<IRenderable> renderables)
|
||||
if (renderable is null)
|
||||
{
|
||||
var result = new List<Segment>();
|
||||
foreach (var renderable in renderables)
|
||||
{
|
||||
result.AddRange(renderable.Render(options, console.Profile.Width));
|
||||
}
|
||||
|
||||
return Segment.Merge(result);
|
||||
throw new ArgumentNullException(nameof(renderable));
|
||||
}
|
||||
|
||||
var context = new RenderContext(console.Profile.Capabilities);
|
||||
var renderables = console.Pipeline.Process(context, new[] { renderable });
|
||||
|
||||
return GetSegments(console, context, renderables);
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<Segment> GetSegments(IAnsiConsole console, RenderContext options, IEnumerable<IRenderable> renderables)
|
||||
{
|
||||
var result = new List<Segment>();
|
||||
foreach (var renderable in renderables)
|
||||
{
|
||||
result.AddRange(renderable.Render(options, console.Profile.Width));
|
||||
}
|
||||
|
||||
return Segment.Merge(result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user