CollectionNavigator.cs 904 B

12345678910111213141516171819202122232425
  1. #nullable disable
  2. using System.Collections;
  3. namespace Terminal.Gui.Views;
  4. /// <inheritdoc cref="CollectionNavigatorBase"/>
  5. /// <remarks>This implementation is based on a static <see cref="Collection"/> of objects.</remarks>
  6. internal class CollectionNavigator : CollectionNavigatorBase, IListCollectionNavigator
  7. {
  8. /// <summary>Constructs a new CollectionNavigator.</summary>
  9. public CollectionNavigator () { }
  10. /// <summary>Constructs a new CollectionNavigator for the given collection.</summary>
  11. /// <param name="collection"></param>
  12. public CollectionNavigator (IList collection) { Collection = collection; }
  13. /// <inheritdoc/>
  14. public IList Collection { get; set; }
  15. /// <inheritdoc/>
  16. protected override object ElementAt (int idx) { return Collection [idx]; }
  17. /// <inheritdoc/>
  18. protected override int GetCollectionLength () { return Collection.Count; }
  19. }