調用方法:
首先要有一個寫入的實體類,必須可以序列化,並且實現IPut接口:
[Serializable()]
操作:
class Item : IPut
{
public string Name { get; set; }
public string Text { get; set; }
public int ID { get; set; }
public override string ToString()
{
return string.Format("ID:{0} Key:{1}", ID, Name);
}
public string Key
{
get { return Name; }
}
}
using (BDBManager manager = new BDBManager("db", "db.dat"))
{
bool success = manager.Set(new Item() { ID = 1000, Name = "Test",Text = "213" });
Console.WriteLine(string.Format("set is {0}", success));
}
using (BDBManager manager = new BDBManager("db", "db.dat"))
{
IPut put = new Item() { Name = "Test" };
bool success = manager.Get(ref put);
Console.WriteLine(string.Format("read is {0},item : {1}", success, put.ToString()));
}
using (BDBManager manager = new BDBManager("db", "db.dat"))
{
IPut put = new Item() { Name = "Test" };
bool success = manager.Remove(put);
Console.WriteLine(string.Format("remove is {0},item : {1}", success, put.ToString()));
}
using (BDBManager manager = new BDBManager("db", "db.dat"))
{
List<IPut> list = manager.Find();
foreach (var item in list)
{
Console.WriteLine(item.ToString());
}
}
Console.WriteLine("end");
Console.ReadKey();