Reorganized commands structure

This commit is contained in:
RogueException
2016-06-21 05:32:49 -03:00
parent 2e8f67e8a4
commit 32ab967f4a
7 changed files with 165 additions and 128 deletions

View File

@@ -0,0 +1,24 @@
using System;
using System.Linq;
using System.Reflection;
namespace Discord.Commands
{
internal class ReflectionUtils
{
internal static object CreateObject(TypeInfo typeInfo)
{
var constructor = typeInfo.DeclaredConstructors.Where(x => x.GetParameters().Length == 0).FirstOrDefault();
if (constructor == null)
throw new InvalidOperationException($"Failed to find a valid constructor for \"{typeInfo.FullName}\"");
try
{
return constructor.Invoke(null);
}
catch (Exception ex)
{
throw new InvalidOperationException($"Failed to create \"{typeInfo.FullName}\"", ex);
}
}
}
}