public void AddModule(Type type) { var assemblyPath = type.Assembly.Location; if (!_assemblies.Contains(assemblyPath)) { _assemblies.Add(assemblyPath); } foreach (var(id, aliases, method) in ModuleUtils.GetMethods(type)) { var classId = id; var counter = 0; while (_classes.ContainsKey(classId)) { classId = id + ++counter; } var className = ToCamelCase(classId) + "Command"; var typeName = Namespace + '.' + className; _classes.Add(classId, new CommandInformation(type, typeName, CreateCommandClass(id, aliases, className, type, method))); } }
public IEnumerable <ICommand> Compile(IEnumerable <Type> typesEnumerable) { var modules = typesEnumerable as Type[] ?? typesEnumerable.ToArray(); var stopwatch = Stopwatch.StartNew(); var commands = modules .SelectMany(t => ModuleUtils.GetMethods(t).Select(m => new ReflectionCommand(m.id, m.aliases, t, m.method, _valueProviders))) .ToArray(); _logger.LogTrace("Compiled {CommandCount} commands from {ModuleCount} modules in {Duration:0.00} ms.", commands.Length, modules.Length, stopwatch.Elapsed.TotalMilliseconds); return(commands); }