Class FtpStateMachine<TStatus>
A base class for a state machine that's triggered by FTP commands.
Implements
Inherited Members
Namespace: FubarDev.FtpServer
Assembly: FubarDev.FtpServer.Abstractions.dll
Syntax
public abstract class FtpStateMachine<TStatus> : IFtpStateMachine<TStatus> where TStatus : Enum
Type Parameters
Name | Description |
---|---|
TStatus | The status type. |
Constructors
| Improve this Doc View SourceFtpStateMachine(IFtpConnection, IEnumerable<FtpStateMachine<TStatus>.Transition>, TStatus)
Initializes a new instance of the FtpStateMachine<TStatus> class.
Declaration
protected FtpStateMachine(IFtpConnection connection, IEnumerable<FtpStateMachine<TStatus>.Transition> transitions, TStatus initialStatus)
Parameters
Type | Name | Description |
---|---|---|
IFtpConnection | connection | The FTP connection. |
IEnumerable<FtpStateMachine.Transition<>> | transitions | The supported transitions. |
TStatus | initialStatus | The initial status. |
Properties
| Improve this Doc View SourceConnection
Gets the connection this state machine belongs to.
Declaration
public IFtpConnection Connection { get; }
Property Value
Type | Description |
---|---|
IFtpConnection |
Status
Gets the current status.
Declaration
public TStatus Status { get; }
Property Value
Type | Description |
---|---|
TStatus |
Methods
| Improve this Doc View SourceExecuteAsync(FtpCommand, CancellationToken)
Executes the given FTP command.
Declaration
public Task<IFtpResponse? > ExecuteAsync(FtpCommand ftpCommand, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
FtpCommand | ftpCommand | The FTP command to execute. |
CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
Task<Nullable<IFtpResponse>> | The task returning the response. |
ExecuteCommandAsync(FtpCommand, CancellationToken)
Execute the command. All status checks are already done.
Declaration
protected abstract Task<IFtpResponse? > ExecuteCommandAsync(FtpCommand ftpCommand, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
FtpCommand | ftpCommand | The FTP command to execute. |
CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
Task<Nullable<IFtpResponse>> | The task returning the response. |
GetPossibleTransitions(TStatus)
Get all possible transitions for a given status.
Declaration
protected IReadOnlyCollection<FtpStateMachine<TStatus>.Transition> GetPossibleTransitions(TStatus status)
Parameters
Type | Name | Description |
---|---|---|
TStatus | status | The status value to get the transitions for. |
Returns
Type | Description |
---|---|
IReadOnlyCollection<FtpStateMachine.Transition<>> | The possible transitions for the given status. |
OnStatusChanged(TStatus, TStatus)
Called when the status was updated.
Declaration
protected virtual void OnStatusChanged(TStatus from, TStatus to)
Parameters
Type | Name | Description |
---|---|---|
TStatus | from | The previous status. |
TStatus | to | The new status. |
Reset()
Resets the state machine to the initial status.
Declaration
public virtual void Reset()
SetStatus(TStatus)
Sets the status to a new value.
Declaration
protected void SetStatus(TStatus status)
Parameters
Type | Name | Description |
---|---|---|
TStatus | status | The new status value. |
T(String)
Translates a message using the current catalog of the active connection.
Declaration
protected string T(string message)
Parameters
Type | Name | Description |
---|---|---|
String | message | The message to translate. |
Returns
Type | Description |
---|---|
String | The translated message. |
T(String, Object[])
Translates a message using the current catalog of the active connection.
Declaration
[StringFormatMethod("message")]
protected string T(string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
String | message | The message to translate. |
Object[] | args | The format arguments. |
Returns
Type | Description |
---|---|
String | The translated message. |