Пример #1
0
        public void persistdb <Key, Value, Data>(DBEngine <Key, Value> db)
        {
            XDocument xml = new XDocument();

            xml.Declaration = new XDeclaration("1.0", "utf-8", "yes");
            XComment comment = new XComment("NoSQL Database");    //title for XML

            xml.Add(comment);
            XElement NoSQLelem = new XElement("NoSQLDB_ELEMENTS");
            XElement type      = new XElement("numbers", typeof(Key));
            XElement payload   = new XElement("name", typeof(Data));

            xml.Add(NoSQLelem);
            NoSQLelem.Add(type);
            NoSQLelem.Add(payload);
            foreach (Key k1 in db.Keys())
            {
                XElement tags = new XElement("open_close");
                XElement key  = new XElement("new_Key", k1);  //tag for new keys generated
                tags.Add(key);
                Value value1;
                db.getValue(k1, out value1);
                DBElement <Key, Data> element = value1 as DBElement <Key, Data>;
                WriteLine(element.showElement());
                XElement dbelement = persistdbelement <Key, Data>(element);
                tags.Add(dbelement);
                NoSQLelem.Add(tags);
                xml.Save("XML_FILE_PROJECT4.xml");                               //XML file name
            }
        }
Пример #2
0
        //----< write simple db elements out to Console >------------------

        public static void show <Key, Value, Data>(this DBEngine <Key, Value> db)
        {
            foreach (Key key in db.Keys())
            {
                Value value;
                db.getValue(key, out value);
                DBElement <Key, Data> elem = value as DBElement <Key, Data>;
                Write("\n\n  -- key = {0} --", key);
                Write(elem.showElement());
            }
        }