熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

C#使用BerkeleyDB操作簡介[4]

2022-06-13   來源: .NET編程 

}
   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();

[]  []  []  []  []  []  []  


From:http://tw.wingwit.com/Article/program/net/201311/14800.html
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.