-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSection.cs
More file actions
56 lines (41 loc) · 1.33 KB
/
Section.cs
File metadata and controls
56 lines (41 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
namespace Menees.Chords;
#region Using Directives
using System.Collections.Generic;
using System.IO;
using System.Linq;
#endregion
/// <summary>
/// An explicit or implicit group of <see cref="Entry"/>s within a <see cref="Document"/>.
/// </summary>
public sealed class Section : Entry, IEntryContainer
{
#region Constructors
/// <summary>
/// Creates a new section with the specified entries.
/// </summary>
/// <param name="entries">The values to include in <see cref="Entries"/>.</param>
/// <param name="annotations">A collection of optional end-of-line annotations.</param>
public Section(IEnumerable<Entry> entries, IEnumerable<Entry>? annotations = null)
: base(annotations)
{
Conditions.RequireNonEmpty(entries);
this.Entries = [.. entries];
}
#endregion
#region Public Properties
/// <summary>
/// Gets the ordered collection of entries within the current section.
/// </summary>
public IReadOnlyList<Entry> Entries { get; }
#endregion
#region Public Methods
/// <inheritdoc/>
public override void Write(TextWriter writer, bool includeAnnotations)
=> WriteJoin(writer, this.Entries, (w, entry) => entry.Write(w, includeAnnotations));
#endregion
#region Protected Methods
/// <inheritdoc/>
protected override void WriteWithoutAnnotations(TextWriter writer)
=> this.Write(writer, false);
#endregion
}