IEvent.cs 684 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Cysharp.Threading.Tasks;
  7. namespace KYFramework
  8. {
  9. public interface IEvent
  10. {
  11. Type GetEventType();
  12. }
  13. public abstract class AEvent<A> : IEvent where A: struct
  14. {
  15. public Type GetEventType()
  16. {
  17. return typeof (A);
  18. }
  19. protected abstract UniTask Run( A a);
  20. public async UniTask Handle( A a)
  21. {
  22. try
  23. {
  24. await Run(a);
  25. }
  26. catch (Exception e)
  27. {
  28. Log.Error(e);
  29. }
  30. }
  31. }
  32. }