2019-06-03 14:57:05 +00:00
|
|
|
using System;
|
|
|
|
using System.Reflection;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
namespace Aurora.Backend.Executors
|
|
|
|
{
|
|
|
|
public abstract class BaseExecutor
|
|
|
|
{
|
|
|
|
public BaseExecutor()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-06-26 01:17:52 +00:00
|
|
|
public ExecutorType ExecutorType { get; protected set; }
|
|
|
|
|
2019-06-03 14:57:05 +00:00
|
|
|
public static BaseExecutor CreateExecutor<T>(ExecutorType executorType) where T : BaseExecutor
|
|
|
|
{
|
|
|
|
MethodInfo method = typeof(T).GetMethod("Create");
|
|
|
|
if (method == null)
|
|
|
|
{
|
|
|
|
throw new InvalidOperationException("Executor must include a 'create' method.");
|
|
|
|
}
|
|
|
|
|
|
|
|
return method.Invoke(null, new object[] { executorType }) as BaseExecutor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public enum ExecutorType
|
|
|
|
{
|
|
|
|
Server,
|
|
|
|
Client
|
|
|
|
}
|
|
|
|
}
|