I have DataAccess class which is derived from DataAccessor. DataAccessor class is the DB base class which I use in all all projects.
Instance method is the helper to create new instance of the DataAccess class. I would like to move Instance method to DataAccessor base class and create new insatnces of derived classes from base class. How to do that?
public class DataAccess : DataAccessor
{
public static DataAccess Instance
{
get
{
return new DataAccess();
}
}
}
public abstract class DataAccessor
{
}
public class Base<T> where T : new()
{
public static T Instance
{
get { return new T(); }
}
}
public class Derived : Base<Derived>
{
}
您是否考虑过抽象工厂模式 ?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.