//TODO: StoreEngineFactory has to go, the engine should be injected directly.
 public Configuration(String folder, String dbName, IStoreEngine db, bool massInsertMode)
 {
     try {
         this.folder = folder;
         this.dbName = dbName;
         this.db     = db;
         //db = StoreEngineFactory.build(folder, dbName, "conf", dbEngine, massInsertMode);
         if (db.contains(Configuration.KEY_NAMES))
         {
             this.keyFieldNames = (String[])db.get(Configuration.KEY_NAMES);
         }
         if (db.contains(Configuration.KEY_MODE))
         {
             this.isKeyed = (bool)db.get(Configuration.KEY_MODE);
         }
         if (keyFieldNames != null)
         {
             for (int i = 0; i < this.keyFieldNames.Length; i++)
             {
                 String keyFieldName = this.keyFieldNames[i];
                 keys[keyFieldName] = (Key)db.get("conf_" + keyFieldName);
             }
         }
     } catch (Exception ex) {
         throw new StoreInitException("Store init error: " + ex.Message);
     }
 }
 public Configuration(String folder, String dbName, IStoreEngine db, Key[] keysList, bool massInsertMode)
 {
     try {
         this.folder = folder;
         this.dbName = dbName;
         this.db     = db;
         //db = StoreEngineFactory.build(folder, dbName, "conf", dbEngine, massInsertMode);
         if (db.contains(Configuration.KEY_NAMES))
         {
             var kfn = db.get(Configuration.KEY_NAMES);
             this.keyFieldNames = kfn as string[];//TODO: FIX JSON STORAGE OR IMPLEMENT ANOTHER
             for (int i = 0; i < this.keyFieldNames.Length; i++)
             {
                 String keyFieldName = this.keyFieldNames[i];
                 this.keys[keyFieldName] = (Key)db.get("conf_" + keyFieldName);
             }
             if (db.contains(Configuration.KEY_MODE))
             {
                 this.isKeyed = (bool)db.get(Configuration.KEY_MODE);
             }
             if (db.contains(Configuration.PRIVATE_MODE))
             {
                 this.isPrivate = true;
             }
         }
         else
         {
             this.keyFieldNames = new String[keysList.Length];
             for (int i = 0; i < keysList.Length; i++)
             {
                 this.keyFieldNames[i]  = keysList[i].keyFieldName;
                 keys[keyFieldNames[i]] = keysList[i];
                 db.set("conf_" + this.keyFieldNames[i], keysList[i]);
                 if (this.keyFieldNames[0] == Configuration.RECORD_LEVEL)
                 {
                     this.isKeyed = false;
                 }
                 else
                 {
                     this.isKeyed = true;
                 }
             }
             db.set(Configuration.KEY_MODE, this.isKeyed);
             db.set(Configuration.KEY_NAMES, this.keyFieldNames);
         }
     } catch (Exception ex) {
         throw new StoreInitException("Store init error: " + ex.Message);
     }
 }