/// <summary> /// Quick method to get TableFile from instance /// </summary> /// <param name="path"></param> /// <param name="useCache"></param> /// <returns></returns> public static TableFile Get(string path, bool useCache = true) { if (_instance == null) { _instance = new DTMySqlModule(); } return(_instance.GetTableFile(path, useCache)); }
/// <summary> /// Do reload the dataTable file: MyTest /// </summary> internal void ReloadAll(bool throwWhenDuplicatePrimaryKey, string customContent = null) { for (var j = 0; j < TabFilePaths.Length; j++) { var tabFilePath = TabFilePaths[j]; TableFile tableFile; if (customContent == null) { tableFile = DTMySqlModule.Get(tabFilePath, false); } else { tableFile = TableFile.LoadFromString(customContent); } using (tableFile) { foreach (var row in tableFile) { DTMySQL_MyTest dataTable; dataTable = new DTMySQL_MyTest(row); if (!_dict.ContainsKey(dataTable.Id)) { dataTable.UpdateToMySQL(); _dict[dataTable.Id] = dataTable; } else { if (throwWhenDuplicatePrimaryKey) { throw new System.Exception(string.Format("DuplicateKey, Class: {0}, File: {1}, Key: {2}", this.GetType().Name, tabFilePath, "Id")); } else { dataTable.Reload(row); } } } } } //UnityEngine.Debug.LogFormat("Reload dataTables: {0}, Row Count: {1}, Reload Count: {2}", GetType(), Count); }