I have 2 C# interfaces like this:
public interface IEvernoteJobListener
{
void CopyS3File(S3Location src, EvernoteLocation des, Action<Exception> complete);
}
public interface ICopyJobListener
{
void CopyS3File(S3Location src, S3Location des, Action<Exception> complete);
}
You can see that they are almost identical besides their second parameter, which makes the implementation nearly identical. What stops me from merge them into a single interface is that EvernoteLocation and S3Location are structs, so I can’t make them inherit from the same parent and thus eliminate the difference between them and only keep one interface and one method.
What are the possible solutions to eliminate the duplication of the interface?
Edit:
The code of implementation might help clarify the question:
public void CopyS3File (S3Location src, EvernoteLocation des, Action<Exception> complete)
{
reader.ReadS3ToFile(src, (file, readExc) => {
if(readExc != null)
{
complete(readExc);
return;
}
// This is a Evernote writer.
writer.WriteFromFile(file, des, writeExc => {
complete(writeExc);
});
});
}
public void CopyS3File (S3Location src, S3Location des, Action<Exception> complete)
{
reader.ReadS3ToFile(src, (file, readExc) => {
if(readExc != null)
{
complete(readExc);
return;
}
// This is a S3 writer.
writer.WriteFromFile(file, des, writeExc => {
complete(writeExc);
});
});
}
You could make the interface generic.
But I don’t know how that helps with your implementation.