我正在为我们的应用程序实现一个持久层,并提出了一个设计,我有一个提供程序,可以让客户端更新单个键值,然后我还有一个事务类,我可以通过它更新多个键值对.
接口是:
public interface IStorageProvider
{
bool GetValue<T>(string key, out T value);
T GetOrCreateValue<T>(string key) where T : new();
bool SetValue<T>(string key, T value);
ITransaction Transaction();
}
public interface ITransaction : IDisposable
{
event EventHandler<TransactionEventArgs> CommitSucceeded;
event EventHandler<TransactionEventArgs> CommitFailed;
bool GetValue<T>(string key, out T value);
bool SetValue<T>(string key, T value);
void Commit();
}
我不喜欢 provider 和 transaction 如何拥有类似的 API,例如GetValueand SetValue。
我希望这是一个接口,IStorageProvider并ITransaction从中派生。你们会推荐什么?
郎朗坤
相关分类