Hi All,
I have a factory which has some concrete sub classes for generating reports (.txt, .csv,.xls) I want to make the interface of the concrete classes to be generic so that i can pass in diff types of parameters (Instead of DataTable i need to use DataSet or some other class instance as argument). Here is my previous interface.
interface IReportCreator
{
bool Create(DataTable dt);
}
I made the interface as generic..like the one below
interface IReportCreator<T>
{
bool Create(T args);
}
Now my question is how can i return the generic interface from the Factory My previous factory code
My previous factory code is like the one below..
class Factory
{
static IReportCreator GetReportCreator(string type)
{
IReportCreator reportCreator = null;
if(type == "txt")
reportCreator = new TextCreator();
if(type == "csv")
reportCreator = new CSVCreator();
return reportCreator;
}
}
And in the cient.. i call like this
IReportCreator repCreator = Factory.GetReportCreator("txt");
repCreator.Create(// the argument);
I want to make the factory as a generic one.. Pls help me to solve this
Any help will be appreciated greatly
Thanks