67 lines
2 KiB
C#
67 lines
2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
|
|
namespace DTestConsoleHelper
|
|
{
|
|
public enum DTestPlatforms
|
|
{
|
|
XONE,
|
|
PS4
|
|
}
|
|
|
|
class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
// parse arguments
|
|
// args[0] => platform
|
|
// args[1] => operation
|
|
// args[2] onwards => additional parameters
|
|
|
|
var platform = args[0];
|
|
|
|
if (!Enum.IsDefined(typeof(DTestPlatforms), platform))
|
|
{
|
|
Console.WriteLine("ERROR ! Platform not found supported XONE and PS4");
|
|
}
|
|
|
|
if (platform == DTestPlatforms.XONE.ToString())
|
|
{
|
|
IDTestPlatforms dTestPlatforms = new DTestXoneHelper();
|
|
var name = CallOperationWithParameters(dTestPlatforms, args);
|
|
Console.WriteLine(name);
|
|
}
|
|
}
|
|
|
|
private static object CallOperationWithParameters(IDTestPlatforms dTestPlatforms, string[] args)
|
|
{
|
|
MethodInfo methodInfo = dTestPlatforms.GetType().GetMethod(args[1]);
|
|
if (methodInfo != null)
|
|
{
|
|
object result = null;
|
|
ParameterInfo[] parameterInfo = methodInfo.GetParameters();
|
|
if (parameterInfo.Length == 0)
|
|
{
|
|
result = methodInfo.Invoke(dTestPlatforms, null);
|
|
}
|
|
else
|
|
{
|
|
List<object> parameters = new List<object>();
|
|
for (int index = 2; index < args.Length; index++)
|
|
{
|
|
parameters.Add(args[index]);
|
|
}
|
|
result = methodInfo.Invoke(dTestPlatforms, parameters.ToArray());
|
|
}
|
|
return result;
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("ERROR ! Un supported function name");
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|