ITreeBuilder.cs 1.3 KB

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