Is Agency a class you control? If so do something like this:
public abstract class GenericDb
{
public abstract void Query(parms);
}
In your Agency Class, you could have
public GenericDb ClientDb {get; set;}
Then have a SqlDb class like:
public class SqlDb : GenericDb
{
public void Query(parms);
}
public class PicDb : GenericDb
{
public void Query(parms);
}
Then this code:
public void Query(Agency agency, Citation queryCitation) {
queryCitation.AgencyCode = agency.AgencyCode;
switch (agency.ClientDb.Type) {
case "SQL":
QueryOracle(agency, queryCitation);
break;
case "PIC":
QueryPick(agency, queryCitation);
break;
}
}
becomes
public void Query(Agency agency, Citation queryCitation) {
queryCitation.AgencyCode = agency.AgencyCode;
agency.ClientDb.Query(queryCitation);
}
Because of inheritance, it will know that ClientDb has a base class of GenericDb. It will know by the type of the ClientDb parameter whether it should run the SqlDb or the PicDb or Oracle etc.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…