I have 40 providers who need to connect to ftp, do something there and close the connection. Thus, all these 40 providers have their own class, and they all have ftp server connections and disconnections, but they all have different processing methods.
So basically, I have 40 classes using this method:
ftp.Connect();
//do something - this is different for all the classes
ftp.Close();
So, something else is different for everyone, it does different things, uses different variables, etc.
What I thought I would do was create a new class that will be created in all 40 providers. This class will have one method that looks something like this:
public void Connect(FTPCredentials credentials, Process process)
{
var ftp = new FtpConnection(credentials.Host, credentials.Username, credentials.Password);
ftp.Open();
ftp.Login();
process(ftp);
ftp.Close();
}
public delegate void Process(FtpConnection ftp);
, , , 40 , ? , , , ftp FtpConnection ftp, , DLL, FtpConnection , Connect.
, :
process(string fileName)
process(string folderName)
, , ?