mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 08:52:50 +08:00
40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Spectre.Console.Rendering
|
|
{
|
|
/// <summary>
|
|
/// An enumerator for <see cref="SegmentLine"/> collections.
|
|
/// </summary>
|
|
public sealed class SegmentLineEnumerator : IEnumerable<Segment>
|
|
{
|
|
private readonly List<SegmentLine> _lines;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="SegmentLineEnumerator"/> class.
|
|
/// </summary>
|
|
/// <param name="lines">The lines to enumerate.</param>
|
|
public SegmentLineEnumerator(IEnumerable<SegmentLine> lines)
|
|
{
|
|
if (lines is null)
|
|
{
|
|
throw new System.ArgumentNullException(nameof(lines));
|
|
}
|
|
|
|
_lines = new List<SegmentLine>(lines);
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public IEnumerator<Segment> GetEnumerator()
|
|
{
|
|
return new SegmentLineIterator(_lines);
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
{
|
|
return GetEnumerator();
|
|
}
|
|
}
|
|
}
|