Browse Source

Fixed null DepMap arg

pull/624/head
Khionu Sybiern 8 years ago
parent
commit
6752eb0886
1 changed files with 3 additions and 5 deletions
  1. +3
    -5
      src/Discord.Net.Commands/Utilities/ReflectionUtils.cs

+ 3
- 5
src/Discord.Net.Commands/Utilities/ReflectionUtils.cs View File

@@ -69,17 +69,15 @@ namespace Discord.Commands
}; };
} }


private static readonly TypeInfo _dependencyTypeInfo = typeof(IDependencyMap).GetTypeInfo();

internal static object GetMember(Type targetType, IDependencyMap map, CommandService service, TypeInfo baseType) internal static object GetMember(Type targetType, IDependencyMap map, CommandService service, TypeInfo baseType)
{ {
object arg; object arg;
if (map == null || !map.TryGet(targetType, out arg))
if (targetType == typeof(IDependencyMap) || targetType == map.GetType())
arg = map;
else if (map == null || !map.TryGet(targetType, out arg))
{ {
if (targetType == typeof(CommandService)) if (targetType == typeof(CommandService))
arg = service; arg = service;
else if (targetType == typeof(IDependencyMap) || targetType == map.GetType())
arg = map;
else else
throw new InvalidOperationException($"Failed to create \"{baseType.FullName}\", dependency \"{targetType.Name}\" was not found."); throw new InvalidOperationException($"Failed to create \"{baseType.FullName}\", dependency \"{targetType.Name}\" was not found.");
} }


Loading…
Cancel
Save