aurora/Aurora/Backend/Executors/BaseExecutor.cs

57 lines
1.3 KiB
C#
Raw Normal View History

2019-06-03 14:57:05 +00:00
using System;
using System.Reflection;
using System.Linq;
namespace Aurora.Backend.Executors
{
public abstract class BaseExecutor
{
protected BaseExecutor()
2019-06-03 14:57:05 +00:00
{
}
public Type ExecutorType { get; protected set; }
2019-06-26 01:17:52 +00:00
public static BaseExecutor CreateExecutor<T>()
2019-06-03 14:57:05 +00:00
{
BaseExecutor executor = null;
if (typeof(T) == typeof(HostExecutor))
{
executor = new HostExecutor();
executor.ExecutorType = typeof(HostExecutor);
}
else if (typeof(T) == typeof(ClientExecutor))
2019-06-03 14:57:05 +00:00
{
executor = new ClientExecutor();
executor.ExecutorType = typeof(ClientExecutor);
}
else
{
throw new InvalidOperationException("Cannot create an executor of type: " + nameof(T));
2019-06-03 14:57:05 +00:00
}
return executor;
2019-06-03 14:57:05 +00:00
}
public abstract void Initialize();
public abstract void Run();
public abstract void Close();
public abstract void GetMembers();
public abstract void GetQueue();
public abstract void AddToQueue();
public abstract void RemoveFromQueue();
2019-06-03 14:57:05 +00:00
}
public enum ExecutorType
{
Server,
Client
}
}