GenericHeld.cs 674 B

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