54 lines
834 B
C#
54 lines
834 B
C#
|
using System;
|
|||
|
|
|||
|
namespace ET
|
|||
|
{
|
|||
|
public interface IEvent
|
|||
|
{
|
|||
|
Type GetEventType();
|
|||
|
}
|
|||
|
|
|||
|
[Event]
|
|||
|
public abstract class AEvent<A>: IEvent where A: struct
|
|||
|
{
|
|||
|
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);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|