filter plugin by names
This commit is contained in:
parent
f032dfc102
commit
cdfd622930
|
|
@ -3,5 +3,6 @@ namespace BotSharp.Abstraction.Plugins.Models
|
|||
public class PluginFilter
|
||||
{
|
||||
public Pagination Pager { get; set; } = new Pagination();
|
||||
public IEnumerable<string>? Names { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,6 +126,12 @@ public class PluginLoader
|
|||
var plugins = GetPlugins(services);
|
||||
var pager = filter?.Pager ?? new Pagination();
|
||||
|
||||
// Apply filter
|
||||
if (!filter.Names.IsNullOrEmpty())
|
||||
{
|
||||
plugins = plugins.Where(x => filter.Names.Any(n => x.Name.IsEqualTo(n))).ToList();
|
||||
}
|
||||
|
||||
return new PagedItems<PluginDef>
|
||||
{
|
||||
Items = plugins.Skip(pager.Offset).Take(pager.Size),
|
||||
|
|
|
|||
Loading…
Reference in a new issue