I have an abstract class called generic, implemented as follows:
public abstract class generic
{
public string creatorID { get; set; }
public string item
To me, this looks like a class factory.
You need a method that takes a DataRow
, looks at its fields, and decides which subclass of generic
should be created for that row. Then it creates the appropriate object newObj
, calls newObj.setParameters(dr)
, and returns newObj
.
Preferably, the actual factory method doesn't take a DataRow
, but rather just the one scalar value (int, string, whatever) that indicates the type to be created.
Perhaps the class factory is passed in by dependency injection; you could go simple or elaborate on this.