-
Notifications
You must be signed in to change notification settings - Fork 70
ServiceCommand
The ServiceCommand is the actor responsible for orchestrating initialization logic, validation/business rule execution, and data proxy invocation. Service Commands inherit from Command and implement ICommand, and are returned by the public methods of service base.
ServiceCommand is meant to serve as an easy way to deliver custom command functionality from your service implementations without the hassle of having to create your own command implementations. However, if you don't find ServiceCommand to be flexible enough, you can also create your own commands that inherit from Peasy.Core.Command or alternatively, implement Peasy.Core.ICommand;
The service command offers many contructor overloads, each requiring different variations of arguments of type Func and Action. This functional design pattern is used to support thread-safety.
For example, many times you will not need initialization logic or business rules to execute before executing logic or interacting with data proxies. In this scenario, you can create a new ServiceCommand specifying methods to execute synchronously and asynchronously.
Here's an example: