Handler (s)},
{FtpCommand.Stou, (parser, s)= gt; parser.StouCommandHandler (s)},
{FtpCommand.User, (parser, s)= gt; parser.UserCommandHandler (s)}
};
# region Command delegatesvirtual Action AborCommand {get; set; } virtual Action CdupCommand {get; set; } virtual Action lt; string gt; CwdCommand {get; set; } virtual Action lt; string gt; DeleCommand {get; set; } virtual Action lt; string gt; ListCommand {get; set; } virtual Action lt; string gt; MdtmCommand {get; set; } virtual Action lt; string gt; MkdCommand {get; set; } virtual Action lt; string gt; NlstCommand {get; set; } virtual Action NoopCommand {get; set; } virtual Action lt; string gt; PassCommand {get; set; } virtual Action PasvCommand {get; set; } virtual Action lt; long, int gt; PortCommand {get; set; } virtual Action PwdCommand {get; set; } virtual Action QuitCommand {get; set; } virtual Action ReinCommand {get; set; } virtual Action lt; string gt; RetrCommand {get; set; } virtual Action lt; string gt; RmdCommand {get; set; } virtual Action lt; string gt; RnfrCommand {get; set; } virtual Action lt; string gt; RntoCommand {get; set; } virtual Action lt; string gt; SizeCommand {get; set; } virtual Action lt; string gt; StorCommand {get; set; } virtual Action lt; string gt; StouCommand {get; set; } virtual Action lt; string gt; UserCommand {get; set; }
# endregion
# region Command handlersabstract void AborCommandHandler (string parameters); abstract void CdupCommandHandler (string parameters); abstract void CwdCommandHandler (string parameters); abstract void DeleCommandHandler (string parameters); abstract void ListCommandHandler (string parameters) ; abstract void MdtmCommandHandler (string parameters); abstract void MkdCommandHandler (string parameters); abstract void NlstCommandHandler (string parameters); abstract void NoopCommandHandler (string parameters); abstract void PassCommandHandler (string parameters); abstract void PasvCommandHandler (string parameters); abstract void PortCommandHandler (string parameters); abstract void PwdCommandHandler (string parameters); abstract void QuitCommandHandler (string parameters); abstract void ReinCommandHandler (string parameters); abstract void RetrCommandHandler (string parameters); abstract void RmdCommandHandler (string parameters); abstract void RnfrCommandHandler (string parameters); abstract void RntoCommandHandler (string parameters); abstract void SizeCommandHandler (string parameters); abstract void StorCommandHandler (string parameters); abstract void StouCommandHandler (string parameters); abstract void UserCommandHandler (string parameters);
# endregion
# region Methods
abstract void Parse (string message);
# endregion
}
class FtpCommandParser: FtpCommandParserBase
{
# region Fields
readonly Action lt; FtpCommand gt; _onUnsupportedCommand;
# endregion
# region ctor
FtpCommandParser (Action lt; FtpCommand gt; onUnsupportedCommandAction=null)
{(onUnsupportedCommandAction == null)
_ onUnsupportedCommand=c= gt; {Throw new UnsupportedFtpCommandException (c); };
_ onUnsupportedCommand=onUnsupportedCommandAction;
}
# endregion
# region Methods
# region Public methods
override void Parse (string message)
{= message.Trim ( raquo ;, n raquo ;, r raquo ;, t ); (string.IsNullOrEmpty (message));
[] parts=message.Split (new [] { }, StringSplitOptions.RemoveEmptyEntries);
ftpCommand; (! FtpCommandHelper.Commands.TryGetValue (parts [0], out ftpCommand)) new UnknownFtpCommandException (parts [0]);
[ftpCommand] (this, string.Join ( raquo ;, parts.Skip (1)));
}
# endregion
# region Private methods
void InvokeCommand (FtpCommand command, Action commandAction)
{(commandAction!=null) ();
_ onUnsupportedCommand (command);
}
void InvokeCommand (FtpCommand command, Action lt; string gt; commandAction, string parameter)
{(commandA...