CollectionNavigator.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace Terminal.Gui {
  6. /// <inheritdoc/>
  7. /// <remarks>This implementation is based on a static <see cref="Collection"/> of objects.</remarks>
  8. public class CollectionNavigator : CollectionNavigatorBase {
  9. /// <summary>
  10. /// The collection of objects to search. <see cref="object.ToString()"/> is used to search the collection.
  11. /// </summary>
  12. public IList Collection { get; set; }
  13. /// <summary>
  14. /// Constructs a new CollectionNavigator.
  15. /// </summary>
  16. public CollectionNavigator () { }
  17. /// <summary>
  18. /// Constructs a new CollectionNavigator for the given collection.
  19. /// </summary>
  20. /// <param name="collection"></param>
  21. public CollectionNavigator (IList collection) => Collection = collection;
  22. /// <inheritdoc/>
  23. protected override object ElementAt (int idx)
  24. {
  25. return Collection [idx];
  26. }
  27. /// <inheritdoc/>
  28. protected override int GetCollectionLength ()
  29. {
  30. return Collection.Count;
  31. }
  32. }
  33. }