I have an abstract class for sending and retrieving messages.
public abstract class MailClient
{
public IAuthentication MailAuthentication { get; set; }
internal MailClient(IAuthentication mailAuthenticaton)
{
this.MailAuthentication = mailAuthenticaton;
}
public abstract State SendMessage(IMessage message);
public abstract List<IMessage> GetEmails();
}
I want to create a concrete class (let say for yahoo email messages). So, I create yahoo client that inherits from the abstract Mail client, and uses YahooMessage object that contains details for the message that needs to be sent or received.
public class YahooClient : MailClient
{
private YahooConfiguration configuration = new YahooConfiguration();
public YahooClient (string username, string password) : base(new YahooAuthentication(username, password))
{
}
public override List<YahooMessage> GetMessages()
{
//Code for retrieving emails
}
public override State SendMessage(YahooMessage message)
{
//Code for sending emails
}
}
YahooMessage implements the IMessage interface, and adds few new properties that are specific for Yahoo.
However, I got error because "SendMessage" and "GetMessages" are not implemented with the correct signature in the Child class (YahooClient). Instead of IMessage I use YahooMessage, that implements the IMessage interface.
This is obviously the wrong approach. What would be the suitable approach to achieve the desired functionality?
Aucun commentaire:
Enregistrer un commentaire