public Schedular(DBEngine<int, DBElement<int, string>> db)
 {
     //setting time interval for persisting of data
     schedular.Interval = 2000;
     schedular.AutoReset = true;
     schedular.Enabled = true;
     //defining method to be called when elapsed event occurs
     //this method persists data into xml file from DBEngine.
     schedular.Elapsed += (object source, ElapsedEventArgs e) =>
     {
         if (count++ < 5)
         {
             "Persisting to Test_DB.xml file".title();
             db.create_xml_from_db(true);
         }
         else
         {
             "Stopped persisting to test_DB.xml file".title();
             schedular.Enabled = false;
             
         }
     };
 }
 static void Main(string[] args)
 {
     
     //<------Create test DB----->
     "Testing for PersistEngine package".title();
     DBEngine<int, DBElement<int, string>> db = new DBEngine<int, DBElement<int, string>>();
     DBEngine<string, DBElement<string, List<string>>> enum_db = new DBEngine<string, DBElement<string, List<string>>>();
     
     for (int i = 0; i < 3; i++)
     {
         DBElement<int, string> elem = new DBElement<int, string>();
         elem.name = "element";
         elem.descr = "test element";
         elem.timeStamp = DateTime.Now;
         elem.children.AddRange(new List<int> { 1, 2, 3 });
         elem.payload = "elem's payload";
         elem.showElement();
         db.insert(i, elem);
     }
     db.showDB();
     WriteLine();
     //<-------Save DB data to XML file--------->
     "Demonstrating XDocument class".title('=');
     WriteLine();
     "Creating XML string using XDocument".title();
     WriteLine();
     db.create_xml_from_db(false);
     //<---Empty DBEngine<int, DBElement<int, string>>--->
     "Removing entries from Db if any".title();
     if (db != null)
     {
         db.removeAll();
     }
     "Current DB state".title();
     db.showDB();
     WriteLine();
     db.create_db_from_xml();
     WriteLine();
     //<---------Create test enum DB-------->
     for (int i = 0; i < 3; i++)
     {
         DBElement<string, List<string>> elem = new DBElement<string, List<string>>();
         elem.name = "element";
         elem.descr = "test element";
         elem.timeStamp = DateTime.Now;
         elem.children.AddRange(new List<string> { "child1", "child2" });
         elem.payload = new List<string> { "payload 1", "payload 2" };
         elem.showEnumerableElement();
         enum_db.insert(i.ToString(), elem);
     }
     enum_db.showEnumerableDB();
     WriteLine();
     //<-------Save enum_DB data to XML file--------->
     "Creating XML string using XDocument".title();
     enum_db.create_xml_from_enum_db(false);
     WriteLine();
     
     if (enum_db != null)
     {
         enum_db.removeAll();
     }
     //<----Empty DBEngine<string, DBElement<string, List<string>>----->
     "Removing entries from enum Db if any".title();
     if (enum_db != null)
     {
         string[] key_array = enum_db.Keys().ToArray();
         foreach (string key in key_array)
         {
             enum_db.remove(key);
         }
     }            
     "Cureent enum DB state".title();
     enum_db.showEnumerableDB();
     WriteLine();
     enum_db.create_enum_db_from_xml();
     WriteLine();
     WriteLine();
     
 }
 private void persist_database(out string str, ref IEnumerator<string> msg_enumerator, DBEngine<int, DBElement<int, string>> db)
 {
     str = "";
       while (msg_enumerator.MoveNext())
       {
     if (msg_enumerator.Current == "Destination")
     {
       msg_enumerator.MoveNext();
       Console.WriteLine(msg_enumerator.Current);
       db.create_xml_from_db(false, msg_enumerator.Current);
       str += "Database Persisted to " + msg_enumerator.Current + " file.";
       return;
     }
       }
       str += "Database persistence failed.";
 }