This repository has been archived on 2020-12-20. You can view files and clone it, but cannot push or open issues or pull requests.
aurora-sharp-desktop/Aurora/Backend/Executors/BaseExecutor.cs
2019-06-03 10:57:05 -04:00

38 lines
999 B
C#

using System;
using System.Reflection;
using System.Linq;
namespace Aurora.Backend.Executors
{
public abstract class BaseExecutor
{
public BaseExecutor()
{
}
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;
// var types = typeof(T).Assembly.GetTypes();
// foreach (Type type in types)
// {
// MethodInfo genericMethod = method.MakeGenericMethod(type);
// genericMethod.Invoke(null, null); // No target, no arguments
// }
}
}
public enum ExecutorType
{
Server,
Client
}
}