Add Dependency Map, Update Assembly Crawler

[Untested] Assembly Crawler will now accept constructors matching: new(), new(CommandService), new(IDependencyMap).

Add IDependencyMap

Add DependencyMap
This commit is contained in:
Christopher F
2016-07-20 17:50:52 -04:00
parent 6e42acba68
commit bbe51012cf
5 changed files with 65 additions and 10 deletions

View File

@@ -164,7 +164,7 @@ namespace Discord.Commands
return loadedModule;
}
public async Task<IEnumerable<Module>> LoadAssembly(Assembly assembly)
public async Task<IEnumerable<Module>> LoadAssembly(Assembly assembly, IDependencyMap dependencyMap = null)
{
var modules = ImmutableArray.CreateBuilder<Module>();
await _moduleLock.WaitAsync().ConfigureAwait(false);
@@ -176,7 +176,7 @@ namespace Discord.Commands
var moduleAttr = typeInfo.GetCustomAttribute<ModuleAttribute>();
if (moduleAttr != null && moduleAttr.Autoload)
{
var moduleInstance = ReflectionUtils.CreateObject(typeInfo);
var moduleInstance = ReflectionUtils.CreateObject(typeInfo, this, dependencyMap);
modules.Add(LoadInternal(moduleInstance, moduleAttr, typeInfo));
}
}