Class CollectionCommand<TEntity, TEndpoint, TElementEndpoint, TElementCommand>
- Namespace
- TypedRest.CommandLine.Commands.Generic
- Assembly
- TypedRest.CommandLine.dll
Command operating on a ICollectionEndpoint<TEntity, TElementEndpoint>.
public abstract class CollectionCommand<TEntity, TEndpoint, TElementEndpoint, TElementCommand> : IndexerCommand<TEndpoint, TElementEndpoint, TElementCommand>, IEndpointCommand where TEntity : class where TEndpoint : ICollectionEndpoint<TEntity, TElementEndpoint> where TElementEndpoint : IElementEndpoint<TEntity> where TElementCommand : IEndpointCommand
Type Parameters
TEntity
The type of entity the endpoint represents.
TEndpoint
The specific type of ICollectionEndpoint<TEntity, TElementEndpoint> to operate on.
TElementEndpoint
The specific type of IElementEndpoint<TEntity> the
TEndpoint
provides for individualTEntity
s.TElementCommand
The specific type of IEndpointCommand is used to handle
TElementEndpoint
s. Must have a public constructor with aTElementEndpoint
parameter.
- Inheritance
-
EndpointCommand<TEndpoint>IndexerCommand<TEndpoint, TElementEndpoint, TElementCommand>CollectionCommand<TEntity, TEndpoint, TElementEndpoint, TElementCommand>
- Implements
- Derived
- Inherited Members
Constructors
CollectionCommand(TEndpoint)
Command operating on a ICollectionEndpoint<TEntity, TElementEndpoint>.
protected CollectionCommand(TEndpoint endpoint)
Parameters
endpoint
TEndpointThe endpoint this command operates on.
Methods
ExecuteAsync(IReadOnlyList<string>, CancellationToken)
Parses command-line arguments and executes the resulting operation.
public override Task ExecuteAsync(IReadOnlyList<string> args, CancellationToken cancellationToken = default)
Parameters
args
IReadOnlyList<string>the console arguments.
cancellationToken
CancellationTokenUsed to cancel the request.
Returns
InputEntities(IReadOnlyList<string>)
Acquires a TEntity
from the user, e.g. by parsing the args
or via JSON on the console.
protected virtual IEnumerable<TEntity> InputEntities(IReadOnlyList<string> args)
Parameters
args
IReadOnlyList<string>
Returns
- IEnumerable<TEntity>
InputEntity(IReadOnlyList<string>)
Acquires a TEntity
from the user, e.g. by parsing the args
or via JSON on the console.
protected virtual TEntity InputEntity(IReadOnlyList<string> args)
Parameters
args
IReadOnlyList<string>
Returns
- TEntity
OutputEntities(IEnumerable<TEntity>)
Outputs a collection of TEntity
s to the user, e.g., via ToString() on the console.
protected virtual void OutputEntities(IEnumerable<TEntity> entities)
Parameters
entities
IEnumerable<TEntity>