PkmnLib.NET/PkmnLib.Dynamic/ScriptHandling/ScriptContainer.cs

34 lines
864 B
C#

using System.Collections;
using System.Diagnostics.CodeAnalysis;
namespace PkmnLib.Dynamic.ScriptHandling;
/// <summary>
/// A holder class for a script. This is used so we can cache a list of these, and iterate over them, even when
/// the underlying script changes.
/// </summary>
public class ScriptContainer : IEnumerable<ScriptContainer>
{
/// <summary>
/// Whether this container is empty.
/// </summary>
[MemberNotNullWhen(false, nameof(ScriptHandling.Script))]
public bool IsEmpty => Script is null;
/// <summary>
/// The script in this container.
/// </summary>
public Script? Script { get; set; } = null;
/// <inheritdoc />
public IEnumerator<ScriptContainer> GetEnumerator()
{
yield return this;
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}