INameScope.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (c) The Avalonia Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using System;
  4. using System.Threading.Tasks;
  5. namespace Avalonia.Controls
  6. {
  7. /// <summary>
  8. /// Defines a name scope.
  9. /// </summary>
  10. public interface INameScope
  11. {
  12. /// <summary>
  13. /// Registers an element in the name scope.
  14. /// </summary>
  15. /// <param name="name">The element name.</param>
  16. /// <param name="element">The element.</param>
  17. void Register(string name, object element);
  18. /// <summary>
  19. /// Finds a named element in the name scope, waits for the scope to be completely populated before returning null
  20. /// </summary>
  21. /// <param name="name">The name.</param>
  22. /// <returns>The element, or null if the name was not found.</returns>
  23. ValueTask<object> FindAsync(string name);
  24. /// <summary>
  25. /// Finds a named element in the name scope, returns immediately, doesn't traverse the name scope stack
  26. /// </summary>
  27. /// <param name="name">The name.</param>
  28. /// <returns>The element, or null if the name was not found.</returns>
  29. object Find(string name);
  30. /// <summary>
  31. /// Marks the name scope as completed, no further registrations will be allowed
  32. /// </summary>
  33. void Complete();
  34. /// <summary>
  35. /// Returns whether further registrations are allowed on the scope
  36. /// </summary>
  37. bool IsCompleted { get; }
  38. }
  39. }