fix: corrected the sequence properties to handle empty lists

This commit is contained in:
Dylan R. E. Moonfire 2022-06-28 02:23:20 -05:00
parent 603c692d7f
commit 7fca466dbb

View file

@ -15,15 +15,15 @@ public class EntitySequence
this.Index = index;
}
public bool HasNext => !this.IsLast;
public bool HasNext => this.Sequence.Count > 0 && !this.IsLast;
public bool HasPrevious => !this.IsFirst;
public bool HasPrevious => this.Sequence.Count > 0 && !this.IsFirst;
public int Index { get; }
public bool IsFirst => this.Index == 0;
public bool IsFirst => this.Sequence.Count > 0 && this.Index == 0;
public bool IsLast => this.Index == this.Sequence.Count - 1;
public bool IsLast => this.Sequence.Count > 0 && this.Index == this.Sequence.Count - 1;
public Entity? Next => this.HasNext ? this.Sequence[this.Index + 1] : null;