抽象类:
abstract class PersistentList<T>
public static PersistentList<T> GetInstanceOfDerivedClass()
{
//???
}
派生类:
public class Managers : PersistentList<Manager>
所以,我想:
Managers managers = Managers.GetInstanceOfDerivedClass();
那可能吗?
选择是:
int clientID = 3;
Managers managers = Managers.For("Client", new { ClientID = clientID});
Managers managers = new Managers(new { ClientID = clientID });
Managers managers = new Managers();
managers.ClientID = clientID;
managers.Load("ForClient");
//alternatively:
Database.Load(managers, "ForClient");
//this works, however requires the above code in the constructor.
Managers managers = new Managers(clientID);
//If the static method on the abstract class (Managers.For) could determine
//the type calling, it would eliminate the need for repetitive constructors.
以上都是可以的,只是想决定一个好的技术。