static void Main(string[] args) { try { IProtoDB <long, Record> db = new ProtoDB <long, Record>(); string path = @"c:\logs\protodbtest"; string name = "test"; Log("Create DB"); db.Open(path, name, ProtoBuf.Serializer.CreateFormatter <Record>(), (x) => x.ID, CreateMode.OpenOrCreate); Log("Start writing"); IEnumerable <long> keys = db.GetKeys(); long maxKey = 0; if (keys.Count() > 0) { maxKey = keys.Max() + 1; } for (long i = maxKey; i < maxKey + 100; i++) { db.Insert(new Record() { ID = i, Value = 17 + i, SValue = new string('Q', 5) }); } //db.Delete(1); Log("Write done"); db.Close(); Log("DB closed"); db = new ProtoDB <long, Record>(); Log("Open DB"); db.Open(path, name, Serializer.CreateFormatter <Record>(), (x) => x.ID, CreateMode.Open); Log("Start read"); Record r = db.Read(1); Log("Read done"); db.Close(); Log("DB closed"); Log("Done"); } catch (Exception e) { Log("Exception :" + e); } Console.ReadKey(); }
private void getArrays(XElement node) { if (node.Attributes().Any(p => p.Name == "Type")) { if (node.Attribute("Type").Value.Contains("Array")) { ProtoDB.Add(node); debugLog.Add("Add proto node: " + node.Name); } } else { foreach (XElement x in node.Elements()) { getArrays(x); } } }