123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using System;
- namespace ET
- {
- public interface IEvent
- {
- Type Type { get; }
- }
-
- public abstract class AEvent<A>: IEvent where A: struct
- {
- public Type Type
- {
- get
- {
- return typeof (A);
- }
- }
- protected abstract ETTask Run(Scene scene, A a);
- public async ETTask Handle(Scene scene, A a)
- {
- try
- {
- await Run(scene, a);
- }
- catch (Exception e)
- {
- Log.Error(e);
- }
- }
- }
- public abstract class BEvent<A> : IEvent
- {
- public Type Type
- {
- get
- {
- return typeof(A);
- }
- }
- protected abstract ETTask OnEvent(A a);
- public async ETTask Handle(A a)
- {
- await OnEvent(a);
- }
- }
- }
|