aspclassic-core/AspClassic.Parser/ModifierCollection.cs
Jelle Luteijn 484dbfc9d9 progress
2022-05-15 11:19:49 +02:00

35 lines
954 B
C#

using System;
using System.Collections.Generic;
namespace AspClassic.Parser;
/// <summary>
/// A read-only collection of modifiers.
/// </summary>
public sealed class ModifierCollection : TreeCollection<Modifier>
{
private readonly ModifierTypes _ModifierTypes;
/// <summary>
/// All the modifiers in the collection.
/// </summary>
public ModifierTypes ModifierTypes => _ModifierTypes;
/// <summary>
/// Constructs a collection of modifiers.
/// </summary>
/// <param name="modifiers">The modifiers in the collection.</param>
/// <param name="span">The location of the parse tree.</param>
public ModifierCollection(IList<Modifier> modifiers, Span span)
: base(TreeType.ModifierCollection, modifiers, span)
{
if (modifiers == null || modifiers.Count == 0)
{
throw new ArgumentException("ModifierCollection cannot be empty.");
}
foreach (Modifier Modifier in modifiers)
{
_ModifierTypes |= Modifier.ModifierType;
}
}
}