I have a interface where I am returning result for a check and this interface has currently 2 implantations but in future it will keeps added.
public interface ICheck
{
Task<CheckReturn> GetCheckReturn(string fileName);
}
public class ATypeCheck : ICheck
{
public async Task<CheckReturn> GetCheckReturn(string fileName)
{
//logic to check A Type
//return CheckReturn with right content type
return await Task.FromResult<CheckReturn>(new CheckReturn { ContentType = "Type A" });
}
}
public class BTypeCheck : ICheck
{
public async Task<CheckReturn> GetCheckReturn(string fileName)
{
//logic to check A Type
//return CheckReturn with right content type
return await Task.FromResult<CheckReturn>(new CheckReturn { ContentType = "Type B" });
}
}
// Future CTypeCheck // Future DTypeCheck
With below code I am able to do only one check validation, but I need to check all the implementation of ICheck
?
static async Task Main(string[] args)
{
ATypeCheck check = new ATypeCheck();
var result = await check.GetCheckReturn("XYZ");
}
Which design pattern help here & how?
Aucun commentaire:
Enregistrer un commentaire