Initial commit.

This commit is contained in:
2019-07-17 21:01:14 +02:00
parent 528d83d6b6
commit db87c14a75
37 changed files with 2261 additions and 3 deletions

View File

@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DearFTP.Connection.Commands
{
class CommandsDispatcher
{
public ICommand[] Commands { get; } = new ICommand[]
{
new ClntCommand(),
new CwdCommand(),
new DeleteCommand(),
new HelpCommand(),
new FeaturesCommand(),
new FileModificationTimeCommand(),
new ListCommand(),
new ListMachineCommand(),
new MakeDirectoryCommand(),
new ParentDirectoryCommand(),
new PassiveCommand(),
new PwdCommand(),
new QuitCommand(),
new RenameCommand(),
new RetrieveCommand(),
new SiteCommand(),
new SizeCommand(),
new StoreCommand(),
new SystemCommand(),
new TypeCommand(),
new UserCommand()
};
public void Dispatch(Session session, string command, string argument)
{
if (command == "END")
{
session.Stop();
return;
}
var commandExecutor = Commands.FirstOrDefault(x => x.Aliases.Contains(command, StringComparer.OrdinalIgnoreCase));
if (commandExecutor == null)
{
session.FtpStream.Send(ResponseCode.NotImplemented, $"Command '{command}' not implemented or invalid");
return;
}
commandExecutor.Execute(session, session.FtpStream, command, argument);
}
}
}