EventPerformer.cs 551 B

123456789101112131415161718192021222324
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace GUI.GUIUtils
  7. {
  8. public class EventPerformer<ListenerType> : LinkedList<ListenerType> where ListenerType : class
  9. {
  10. public void AddSafe(ListenerType listener)
  11. {
  12. AddFirst(listener);
  13. }
  14. public void Perform(Action<ListenerType> performFunc)
  15. {
  16. foreach (var it in this)
  17. {
  18. performFunc?.Invoke(it);
  19. }
  20. }
  21. }
  22. }