ITreeBuilder.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. #nullable disable
  2. namespace Terminal.Gui.Views;
  3. /// <summary>
  4. /// Interface for supplying data to a <see cref="TreeView{T}"/> on demand as root level nodes are expanded by the
  5. /// user
  6. /// </summary>
  7. public interface ITreeBuilder<T>
  8. {
  9. /// <summary>Returns true if <see cref="CanExpand"/> is implemented by this class</summary>
  10. /// <value></value>
  11. bool SupportsCanExpand { get; }
  12. /// <summary>
  13. /// Returns true/false for whether a model has children. This method should be implemented when
  14. /// <see cref="GetChildren"/> is an expensive operation otherwise <see cref="SupportsCanExpand"/> should return false
  15. /// (in which case this method will not be called)
  16. /// </summary>
  17. /// <remarks>
  18. /// Only implement this method if you have a very fast way of determining whether an object can have children e.g.
  19. /// checking a Type (directories can always be expanded)
  20. /// </remarks>
  21. /// <param name="toExpand"></param>
  22. /// <returns></returns>
  23. bool CanExpand (T toExpand);
  24. /// <summary>
  25. /// Returns all children of a given <paramref name="forObject"/> which should be added to the tree as new branches
  26. /// underneath it
  27. /// </summary>
  28. /// <param name="forObject"></param>
  29. /// <returns></returns>
  30. IEnumerable<T> GetChildren (T forObject);
  31. }