Skip to content

Commit

Permalink
Update commands.md (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
guibranco authored Sep 1, 2024
1 parent 0bf4fcd commit f489caa
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions docs/user-guide/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
## Definition

Commands are a way to execute one or more actions based on a class (the command itself).
Commands are defined as a simple class, inherited from `ICommand` interface.
Commands are defined as a simple class inherited from the `ICommand` interface.

Each command can be handled by one, and only one of command handlers.
Each command can be handled by one and only one of the command handlers.

The command handler class inherit from `ICommandHandler<TCommand, TResult>` interface and must implement the `TResult Handle(TCommand command).
The command handler class inherits from the `ICommandHandler<TCommand, TResult>` interface and must implement the `TResult Handle(TCommand command)`.

For example, the `HelloWorldCommand` class, defined below is a simple class without methods, properties or fields and is used to trigger `HelloWorldCommandHandler`:
For example, the `HelloWorldCommand` class, defined below, is a simple class without methods, properties, or fields and is used to trigger `HelloWorldCommandHandler`:

Command class:

Expand All @@ -27,7 +27,7 @@ public class HelloWorldCommandHandler : ICommandHandler<HelloWorldCommand, strin
}
```

To trigger the command handler just call the `CommandsConsumer.Raise` method from any part of your code:
To trigger the command handler, just call the `CommandsConsumer.Raise` method from any part of your code:

```cs
CommandsConsumer.Raise<HelloWorldCommand, string>(new HelloWorldCommand());
Expand All @@ -38,7 +38,7 @@ CommandsConsumer.Raise<HelloWorldCommand, string>(new HelloWorldCommand());

### Returning a class as a result

In this example, the command has some properties and the handler will give a result:
In this example, the command has some properties, and the handler will give the result:

```cs
// The command class.
Expand All @@ -55,7 +55,7 @@ public class ResultSomeCommand(int newQuantity)
public int Quantity { get; } = newQuantity;
}

// The command handler class. Each event can be handled by one, and only one handler.
// The command handler class. Each event can be handled by one and only one handler.
public class SomeCommandHandler : ICommandHandler<SomeCommand, ResultSomeCommand>
{
//constructor of the class, with dependencies...
Expand Down

0 comments on commit f489caa

Please sign in to comment.