GenericHeld.cs 694 B

12345678910111213141516171819202122
  1. #nullable enable
  2. namespace Terminal.Gui.Drivers;
  3. /// <summary>
  4. /// Implementation of <see cref="IHeld"/> for <see cref="AnsiResponseParser{TInputRecord}"/>
  5. /// </summary>
  6. /// <typeparam name="TInputRecord"></typeparam>
  7. internal class GenericHeld<TInputRecord> : IHeld
  8. {
  9. private readonly List<Tuple<char, TInputRecord>> held = [];
  10. public void ClearHeld () { held.Clear (); }
  11. public string? HeldToString () { return new (held.Select (h => h.Item1).ToArray ()); }
  12. public IEnumerable<object> HeldToObjects () { return held; }
  13. public void AddToHeld (object o) { held.Add ((Tuple<char, TInputRecord>)o); }
  14. /// <inheritdoc/>
  15. public int Length => held.Count;
  16. }