Skip to content

Commit 36cf7d5

Browse files
committed
Refactor namespace layout
1 parent 9bbcc8e commit 36cf7d5

20 files changed

+53
-105
lines changed

docs-src/commands.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@ namespace MyCommandPlugin
4949

5050
## Run a Command
5151

52-
Create a class that implements **InEngine.Core.IOptions** in the same assembly as the command class.
52+
Create a class that extends **InEngine.Core.AbstractPlugin** in the same assembly as the command class.
5353
Add a VerbOptions attribute, from the CommandLine namespace, that defines the name of the command.
54-
Optional help text can also be specified in the VerbOption attribute.
55-
The help text can be auto-generated from the attribute or manually specified in the GetUsage method if desired.
5654

5755
```c#
5856
using CommandLine;
@@ -61,16 +59,10 @@ using InEngine.Core;
6159

6260
namespace MyCommandPlugin
6361
{
64-
public class MyOptions : IOptions
62+
public class MyOptions : AbstractPlugin
6563
{
6664
[VerbOption("my-command", HelpText="My example command.")]
6765
public MyCommand MyCommand { get; set; }
68-
69-
[HelpVerbOption]
70-
public string GetUsage(string verb)
71-
{
72-
return HelpText.AutoBuild(this, verb);
73-
}
7466
}
7567
}
7668
```

docs-src/scheduling.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Another advantage is that there is no overhead from managing additional state in
1515

1616
## Scheduling a Command
1717

18-
A job schedule is created by adding a class to your plugin assembly that implements the **InEngine.Core.ICommandSchedule** interface.
18+
A job schedule is created by adding a class to a plugin assembly that extends the **InEngine.Core.AbstractPlugin** class.
1919

2020
This is a simple example:
2121

@@ -25,9 +25,9 @@ using InEngine.Core;
2525

2626
namespace MyCommandPlugin
2727
{
28-
public class CommandSchedule : ICommandSchedule
28+
public class MySchedulePlugin : AbstractPlugin
2929
{
30-
public void Schedule(ISchedule schedule)
30+
public override void Schedule(ISchedule schedule)
3131
{
3232
// Schedule some jobs
3333
}
@@ -36,7 +36,7 @@ namespace MyCommandPlugin
3636
```
3737

3838
The InEngine.NET scheduler automatically discovers this class in your plugin assembly.
39-
It will call the **ICommandSchedule.Schedule** method with an initialized **InEngine.Scheduling.Schedule** object.
39+
It will call the **AbstractPlugin.Schedule** method with an initialized **InEngine.Scheduling.Schedule** object.
4040

4141
This is a command schedule class with a few scheduling examples:
4242

@@ -46,9 +46,9 @@ using InEngine.Core;
4646

4747
namespace MyCommandPlugin
4848
{
49-
public class CommandSchedule : ICommandSchedule
49+
public class MySchedulePlugin : AbstractPlugin
5050
{
51-
public void Schedule(ISchedule schedule)
51+
public override void Schedule(ISchedule schedule)
5252
{
5353
/*
5454
* Run MyCommand every five minutes.

src/InEngine.Core/AbstractCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace InEngine.Core
1010
{
11-
abstract public class AbstractCommand : IFailed, IJob, IWrite, IHasCommandLifeCycle
11+
abstract public class AbstractCommand : IJob, IWrite, IHasCommandLifeCycle
1212
{
1313
public CommandLifeCycle CommandLifeCycle { get; set; }
1414
public Write Write { get; set; }

src/InEngine.Core/AbstractPlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace InEngine.Core
77
{
8-
public class AbstractPlugin : IPluginType
8+
public class AbstractPlugin : IPlugin
99
{
1010
public virtual void Schedule(ISchedule schedule)
1111
{}

src/InEngine.Core/CommandLifeCycle.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using InEngine.Core.Exceptions;
3+
using InEngine.Core.IO;
34

45
namespace InEngine.Core
56
{

src/InEngine.Core/IFailed.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/InEngine.Core/MailSettings.cs renamed to src/InEngine.Core/IO/MailSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace InEngine.Core
1+
namespace InEngine.Core.IO
22
{
33
public class MailSettings
44
{

src/InEngine.Core/IPluginType.cs renamed to src/InEngine.Core/IPlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace InEngine.Core
44
{
5-
public interface IPluginType
5+
public interface IPlugin
66
{
77
void Schedule(ISchedule schedule);
88
string GetUsage(string verb);

src/InEngine.Core/InEngine.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<Folder Include="Scheduling\Commands\" />
3737
<Folder Include="Queuing\LifeCycle\" />
3838
<Folder Include="Queuing\Message\" />
39+
<Folder Include="Scheduling\LifeCycle\" />
3940
</ItemGroup>
4041
<ItemGroup>
4142
<Reference Include="System.ComponentModel.DataAnnotations" />

src/InEngine.Core/Plugin.cs renamed to src/InEngine.Core/PluginAssembly.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,31 @@
88

99
namespace InEngine.Core
1010
{
11-
public class Plugin
11+
public class PluginAssembly
1212
{
1313
public Assembly Assembly { get; set; }
1414
public string Name { get { return Assembly.GetName().Name; } }
1515
public string Version { get { return Assembly.GetName().Version.ToString(); } }
1616

17-
public Plugin(Assembly assembly)
17+
public PluginAssembly(Assembly assembly)
1818
{
1919
Assembly = assembly;
2020
}
2121

22-
public static Plugin LoadFrom(string assemblyPath)
22+
public static PluginAssembly LoadFrom(string assemblyPath)
2323
{
2424
var path = Path.Combine(InEngineSettings.BasePath, assemblyPath);
2525
try
2626
{
27-
return new Plugin(Assembly.LoadFrom(path));
27+
return new PluginAssembly(Assembly.LoadFrom(path));
2828
}
2929
catch (Exception exception)
3030
{
3131
throw new PluginNotFoundException($"Plugin not found at {path}", exception);
3232
}
3333
}
3434

35-
public List<T> Make<T>() where T : class, IPluginType
35+
public List<T> Make<T>() where T : class, IPlugin
3636
{
3737
return Assembly
3838
.GetTypes()
@@ -41,12 +41,12 @@ public List<T> Make<T>() where T : class, IPluginType
4141
.ToList();
4242
}
4343

44-
public static List<Plugin> Load<T>() where T : IPluginType
44+
public static List<PluginAssembly> Load<T>() where T : IPlugin
4545
{
46-
var pluginList = new List<Plugin>();
46+
var pluginList = new List<PluginAssembly>();
4747
try
4848
{
49-
pluginList.Add(new Plugin(Assembly.GetExecutingAssembly()));
49+
pluginList.Add(new PluginAssembly(Assembly.GetExecutingAssembly()));
5050
}
5151
catch (Exception exception)
5252
{
@@ -62,7 +62,7 @@ public static List<Plugin> Load<T>() where T : IPluginType
6262
try
6363
{
6464
if (assembly.GetTypes().Any(y => y.IsClass && typeof(T).IsAssignableFrom(y)))
65-
pluginList.Add(new Plugin(assembly));
65+
pluginList.Add(new PluginAssembly(assembly));
6666
}
6767
catch (Exception exception)
6868
{

0 commit comments

Comments
 (0)