public static ModuleHelpData FromModuleInfo(ModuleInfo module) { var moduleName = module.Name; var suffixPosition = moduleName.IndexOf("Module", StringComparison.Ordinal); if (suffixPosition > -1) { moduleName = module.Name.Substring(0, suffixPosition).Humanize(); } var ret = new ModuleHelpData { Name = moduleName, Summary = string.IsNullOrWhiteSpace(module.Summary) ? "No Summary" : module.Summary }; foreach (var command in module.Commands) { if (command.Preconditions.Any(precon => precon is RequireOwnerAttribute) || command.Attributes.Any(attr => attr is HiddenFromHelpAttribute)) { continue; } ret.Commands.AddRange(CommandHelpData.FromCommandInfo(command)); } return(ret); }
public static ModuleHelpData FromModuleInfo(ModuleInfo module) { var moduleName = module.Name; var suffixPosition = moduleName.IndexOf("Module", StringComparison.Ordinal); if (suffixPosition > -1) { moduleName = module.Name.Substring(0, suffixPosition).Humanize(); } moduleName = moduleName.ApplyCase(LetterCasing.Title); var ret = new ModuleHelpData { Name = moduleName, Summary = string.IsNullOrWhiteSpace(module.Summary) ? "No Summary" : module.Summary, Commands = module.Commands .Where(x => !ShouldBeHidden(x)) .Select(x => CommandHelpData.FromCommandInfo(x)) .ToArray(), }; return(ret); bool ShouldBeHidden(CommandInfo command) => command.Preconditions.Any(x => x is RequireOwnerAttribute) || command.Attributes.Any(x => x is HiddenFromHelpAttribute); }
public List <ModuleHelpData> GetData() { if (_cachedHelpData == null) { _cachedHelpData = new List <ModuleHelpData>(); foreach (var module in _commandService.Modules) { if (module.Attributes.Any(attr => attr is HiddenFromHelpAttribute)) { continue; } _cachedHelpData.Add(ModuleHelpData.FromModuleInfo(module)); } } return(_cachedHelpData); }
public static ModuleHelpData FromModuleInfo(ModuleInfo module) { var ret = new ModuleHelpData { Name = module.Name, Summary = module.Summary }; foreach (var command in module.Commands) { if (command.Preconditions.Any(precon => precon is RequireOwnerAttribute) || command.Attributes.Any(attr => attr is HiddenFromHelpAttribute)) { continue; } ret.Commands.AddRange(CommandHelpData.FromCommandInfo(command)); } return(ret); }
/// <inheritdoc /> public IReadOnlyCollection <ModuleHelpData> GetModuleHelpData() => LazyInitializer.EnsureInitialized(ref _cachedHelpData, () => _commandService.Modules .Where(x => !x.Attributes.Any(attr => attr is HiddenFromHelpAttribute)) .Select(x => ModuleHelpData.FromModuleInfo(x)) .ToArray());