/// <summary> /// Initializes a new instance of the <see cref="CommandInformation"/> class. /// </summary> /// <param name="name">The name of the command.</param> /// <param name="summary">The summary of the command.</param> /// <param name="aliases">The aliases of the command, if any.</param> /// <param name="parameters">The parameters of the command, if any.</param> /// <param name="module">The module the command belongs to.</param> private CommandInformation ( string name, string summary, List <string> aliases, ParameterDefinition[] parameters, ModuleInformation module ) { this.Name = name; this.Summary = summary; this.Aliases = aliases; this.Parameters = parameters; this.Module = module; }
public static bool TryCreate ( MethodDefinition commandMethod, ModuleInformation module, [NotNullWhen(true)] out CommandInformation?information ) { information = null; if (!commandMethod.TryGetCommandName(out var name)) { return(false); } if (!commandMethod.TryGetSummary(out var summary)) { summary = string.Empty; } if (!commandMethod.TryGetAliases(out var aliases)) { aliases = new string[] { }; } var allAliases = new List <string> { name }; allAliases.AddRange(aliases); allAliases = allAliases.Distinct().ToList(); var parameters = commandMethod.HasParameters ? commandMethod.Parameters.ToArray() : new ParameterDefinition[] { }; information = new CommandInformation ( name, summary, allAliases, parameters, module ); return(true); }