}
if (dataBufferLength < dataSize)
{
dataStreamSetLength(dataSize);
data = DbEntryOut(dataStreamGetBuffer());
}
continue;
case ReadStatusSuccess:
dataStreamPosition = ;
dataStreamSetLength(dataSize);
cust = (IPut)formatterDeserialize(dataStream);
return true;
default:
return false;
}
} while (true);
}
六完整操作封装
public interface IPut
{
string Key { get; }
}
public class BDBManager : IDisposable
{
/// <summary>
/// 数据库目录
/// </summary>
private string directory;
/// <summary>
/// 数据库文件名
/// </summary>
private string dbName;
private DbBTree btree;
private Txn txn;
private Db db;
private Env env;
/// <summary>
/// 二进制序列化
/// </summary>
private BinaryFormatter formatter;
/// <summary>
/// 键内存流
/// </summary>
private MemoryStream keyStream;
/// <summary>
/// 内容内存流
/// </summary>
private MemoryStream dataStream;
public BDBManager(string directory string dbName)
{
thisdirectory = directory;
thisdbName = dbName;
Init();
StreamInit();
}
public bool Set(IPut put)
{
Reset();
[] [] [] [] [] [] []