G
Guest
Hi
Have a singleton class like this.
public sealed class ProductAdapter
{
private static readonly ProductAdapter instance = new
ProductAdapter();
private ProductAdapter(){}
public static ProductAdapter Instance
{
get
{
return instance;
}
}
public int Save()
{
return 0;
}
}
But there will be many more xxxAdapter classes so I wonder how I can use
generics to have a abstract AdapterBase class, like below, but as a
singleton.
public abstract class AdapterBase<T>
{
public abstract int Save(T t);
public abstract void Update(T t);
public abstract void Delete(int id);
public abstract void DeleteAll(int id);
public abstract T GetObject();
public abstract List<T> GetCollection();
}
Have a singleton class like this.
public sealed class ProductAdapter
{
private static readonly ProductAdapter instance = new
ProductAdapter();
private ProductAdapter(){}
public static ProductAdapter Instance
{
get
{
return instance;
}
}
public int Save()
{
return 0;
}
}
But there will be many more xxxAdapter classes so I wonder how I can use
generics to have a abstract AdapterBase class, like below, but as a
singleton.
public abstract class AdapterBase<T>
{
public abstract int Save(T t);
public abstract void Update(T t);
public abstract void Delete(int id);
public abstract void DeleteAll(int id);
public abstract T GetObject();
public abstract List<T> GetCollection();
}