public CommandContainerManager(ILifetimeScope scope, ICommandContainer container, ILogger <CommandContainerManager> logger) { CommandContainer = container; CommandContainerType = container.GetType(); Logger = logger; CurrentScope = scope; }
/// <summary> /// Add all commands in a command container /// </summary> /// <param name="container"></param> internal void AddCommands(ICommandContainer container) { MethodInfo[] methods = container.GetType().GetMethods(); for (int i = 0; i < methods.Length; i++) { MethodInfo method = methods[i]; if (method.GetCustomAttribute <Command>() != null) { AddCommand(container, method); } } }
public CommandHelp(ILifetimeScope scope, ICommandContainer container, ICommandContainerManager manager) { CommandContainerType = container.GetType(); var containerLoggerType = typeof(ILogger <>).MakeGenericType(CommandContainerType); Logger = scope.Resolve(containerLoggerType) as ILogger; CommandInformation = new Dictionary <string, CommandInfo>(); foreach (var(methodInfo, handlerAttr, _) in manager.ResolveHandlers()) { var description = methodInfo.GetCustomAttribute <CommandDescriptionAttribute>()?.Description ?? "-"; CommandInformation.Add(handlerAttr.Command, new CommandInfo() { Name = handlerAttr.Command, Description = description }); } }