2
0

ITreeBuilder.cs 1.3 KB

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