-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathAbstractPlugin.cs
More file actions
33 lines (29 loc) · 942 Bytes
/
AbstractPlugin.cs
File metadata and controls
33 lines (29 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System.Collections.Generic;
using System.Linq;
using CommandLine;
using CommandLine.Text;
using InEngine.Core.Scheduling;
namespace InEngine.Core;
public abstract class AbstractPlugin : IPlugin
{
public virtual void Schedule(ISchedule schedule)
{}
[HelpVerbOption]
public virtual string GetUsage(string verb)
{
var helpText = HelpText.AutoBuild(this, verb);
helpText.Heading = $"{GetType().Assembly.GetName().Name} {GetType().Assembly.GetName().Version.ToString()}";
return helpText;
}
public IEnumerable<VerbOptionAttribute> GetVerbOptions()
{
return GetType()
.GetProperties()
.SelectMany(property => {
return property.GetCustomAttributes(typeof(VerbOptionAttribute), true)
.Select(verb => verb as VerbOptionAttribute);
})
.OrderBy(x => x.LongName)
.ToList();
}
}