private Tuple <FtpCommand, IFtpCommandBase, bool> FindCommandHandler(FtpCommand command) { if (!CommandHandlers.TryGetValue(command.Name, out var handler)) { return(null); } if (!string.IsNullOrWhiteSpace(command.Argument) && handler is IFtpCommandHandlerExtensionHost extensionHost) { var extensionCommand = FtpCommand.Parse(command.Argument); if (extensionHost.Extensions.TryGetValue(extensionCommand.Name, out var extension)) { return(Tuple.Create(extensionCommand, (IFtpCommandBase)extension, extension.IsLoginRequired ?? handler.IsLoginRequired)); } } return(Tuple.Create(command, (IFtpCommandBase)handler, handler.IsLoginRequired)); }
private Tuple <FtpCommand, FtpCommandHandlerBase, bool> FindCommandHandler(FtpCommand command) { FtpCommandHandler handler; if (!CommandHandlers.TryGetValue(command.Name, out handler)) { return(null); } var extensionHost = handler as IFtpCommandHandlerExtensionHost; if (!string.IsNullOrWhiteSpace(command.Argument) && extensionHost != null) { var extensionCommand = FtpCommand.Parse(command.Argument); FtpCommandHandlerExtension extension; if (extensionHost.Extensions.TryGetValue(extensionCommand.Name, out extension)) { return(Tuple.Create(extensionCommand, (FtpCommandHandlerBase)extension, extension.IsLoginRequired ?? handler.IsLoginRequired)); } } return(Tuple.Create(command, (FtpCommandHandlerBase)handler, handler.IsLoginRequired)); }
private FtpCommand CreateFtpCommand(byte[] command) { var message = Encoding.GetString(command, 0, command.Length); return(FtpCommand.Parse(message)); }