public CommandInfo(CommandInfo?parent, ConfiguredCommand prototype) { Parent = parent; Name = prototype.Name; Aliases = new HashSet <string>(prototype.Aliases); Description = prototype.Description; Data = prototype.Data; CommandType = prototype.CommandType; SettingsType = prototype.SettingsType; Delegate = prototype.Delegate; IsDefaultCommand = prototype.IsDefaultCommand; IsHidden = prototype.IsHidden; Children = new List <CommandInfo>(); Parameters = new List <CommandParameter>(); Examples = prototype.Examples ?? new List <string[]>(); if (CommandType != null && string.IsNullOrWhiteSpace(Description)) { var description = CommandType.GetCustomAttribute <DescriptionAttribute>(); if (description != null) { Description = description.Description; } } }
public static void Setup() { Logger = BetterEditor.Logger; StoredCommands.Clear(); IEnumerable <Type> CommandTypes = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.GetCustomAttribute <CommandInfo>() != null); foreach (Type CommandType in CommandTypes) { string CommandId = CommandType.GetCustomAttribute <CommandInfo>().Id; StoredCommands.Add(CommandId, (BECommand)CommandType.GetConstructors().First().Invoke(null, null)); } }
public CommandInfo(CommandInfo parent, ConfiguredCommand prototype) { Parent = parent; Name = prototype.Name; Description = prototype.Description; CommandType = prototype.CommandType; SettingsType = prototype.SettingsType; IsDefaultCommand = prototype.IsDefaultCommand; Children = new List <CommandInfo>(); Parameters = new List <CommandParameter>(); Examples = prototype.Examples ?? new List <string[]>(); if (!IsBranch) { var description = CommandType.GetCustomAttribute <DescriptionAttribute>(); if (description != null) { Description = description.Description; } } }