zxl
/
CTT
forked from Cal/CTT
1
0
Fork 0
CTT/Unity/Assets/Model/Core/Event/IEvent.cs

54 lines
818 B
C#

using System;
namespace ET
{
public interface IEvent
{
Type GetEventType();
}
[Event]
public abstract class AEvent<A>: IEvent
{
public Type GetEventType()
{
return typeof (A);
}
public abstract ETTask Run(A args);
public async ETTask Handle(A args)
{
try
{
await Run(args);
}
catch (Exception e)
{
Log.Error(e);
}
}
}
[Event]
public abstract class AEvent_Sync<A> : IEvent where A : struct
{
public Type GetEventType()
{
return typeof(A);
}
public abstract void Run(A args);
public void Handle(A args)
{
try
{
Run(args);
}
catch (Exception e)
{
Log.Error(e);
}
}
}
}