Skip to content

Commit 1e3c8ea

Browse files
committed
Replace ICommand with AbstractCommand everywhere
1 parent 6a82468 commit 1e3c8ea

File tree

14 files changed

+17
-43
lines changed

14 files changed

+17
-43
lines changed

docs-src/commands.md

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,7 @@ dotnet add package InEngine.Core
2828
paket add InEngine.Core
2929
```
3030

31-
Adding a class that implements **InEngine.Core.ICommand** is the simplest way to create a command.
32-
33-
```c#
34-
using System;
35-
using InEngine.Core;
36-
37-
namespace MyCommandPlugin
38-
{
39-
public class MyCommand : ICommand
40-
{
41-
public void Run()
42-
{
43-
Console.WriteLine("Hello, world!");
44-
}
45-
}
46-
}
47-
```
48-
49-
A command that implements ICommand can be run directly or [queued](queuing), but it cannot be [scheduled](scheduling).
50-
Extending the **InEngine.Core.AbstractCommand** class adds extra functionality, like a progress bar, and the ability to schedule the command using the scheduler.
31+
To create a class command, extend the **InEngine.Core.AbstractCommand** class.
5132
Minimally, the Run method should be overridden.
5233

5334
```c#

src/InEngine.Commands/Sample/Minimal.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
namespace InEngine.Commands.Sample
44
{
55
/*
6-
* At a minimum, a command must implement the ICommand interface.
6+
* At a minimum, a command must implement the AbstractCommand interface.
77
*
88
* A command result must be returned from the Run method.
99
* The command result has an optional message. This is especially helpful
1010
* when the command does not finish successfully.
1111
*/
12-
public class Minimal : ICommand
12+
public class Minimal : AbstractCommand
1313
{
1414
public void Run()
1515
{

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 : ICommand, IFailed, IJob, IWrite, IHasCommandLifeCycle
11+
abstract public class AbstractCommand : IFailed, IJob, IWrite, IHasCommandLifeCycle
1212
{
1313
public CommandLifeCycle CommandLifeCycle { get; set; }
1414
public Write Write { get; set; }

src/InEngine.Core/ICommand.cs

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

src/InEngine.Core/Plugin.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ public static List<Plugin> Load<T>() where T : IPluginType
7474
return pluginList.OrderBy(x => x.Name).ToList();
7575
}
7676

77-
public ICommand CreateCommandFromClass(string fullCommandName)
77+
public AbstractCommand CreateCommandFromClass(string fullCommandName)
7878
{
79-
return Assembly.CreateInstance(fullCommandName) as ICommand;
79+
return Assembly.CreateInstance(fullCommandName) as AbstractCommand;
8080
}
8181

82-
public ICommand CreateCommandFromVerb(string verbName)
82+
public AbstractCommand CreateCommandFromVerb(string verbName)
8383
{
8484
var commandClassNames = new List<string>();
8585
var optionsList = Make<IOptions>();
@@ -95,7 +95,7 @@ public ICommand CreateCommandFromVerb(string verbName)
9595
throw new AmbiguousCommandException(verbName);
9696
if (commandCount == 0)
9797
throw new CommandNotFoundException(verbName);
98-
return Assembly.CreateInstance(commandClassNames.First()) as ICommand;
98+
return Assembly.CreateInstance(commandClassNames.First()) as AbstractCommand;
9999
}
100100
}
101101
}

src/InEngine.Core/Queuing/Clients/FileClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public string FailedQueuePath
4242
}
4343
}
4444

45-
public void Publish(ICommand command)
45+
public void Publish(AbstractCommand command)
4646
{
4747
if (!Directory.Exists(PendingQueuePath))
4848
Directory.CreateDirectory(PendingQueuePath);

src/InEngine.Core/Queuing/Clients/RedisClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class RedisClient : IQueueClient
2929
public bool UseCompression { get; set; }
3030
public int RedisDb { get; set; }
3131

32-
public void Publish(ICommand command)
32+
public void Publish(AbstractCommand command)
3333
{
3434
Redis.ListLeftPush(
3535
PendingQueueName,

src/InEngine.Core/Queuing/Clients/SyncClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class SyncClient : IQueueClient
99
public string QueueName { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
1010
public bool UseCompression { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
1111

12-
public void Publish(ICommand command)
12+
public void Publish(AbstractCommand command)
1313
{
1414
command.Run();
1515
}

src/InEngine.Core/Queuing/Commands/Publish.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class Publish : AbstractCommand
2222
[Option("secondary", DefaultValue = false, HelpText = "Publish the command to the secondary queue.")]
2323
public bool UseSecondaryQueue { get; set; }
2424

25-
public ICommand Command { get; set; }
25+
public AbstractCommand Command { get; set; }
2626
public QueueAdapter Queue { get; set; }
2727

2828
public override void Run()

src/InEngine.Core/Queuing/IQueueClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public interface IQueueClient
77
string QueueBaseName { get; set; }
88
string QueueName { get; set; }
99
bool UseCompression { get; set; }
10-
void Publish(ICommand command);
10+
void Publish(AbstractCommand command);
1111
ICommandEnvelope Consume();
1212
long GetPendingQueueLength();
1313
long GetInProgressQueueLength();

0 commit comments

Comments
 (0)