private _ReloadAll ( bool throwWhenDuplicatePrimaryKey ) : void | ||
throwWhenDuplicatePrimaryKey | bool | |
리턴 | void |
void _ReloadAll(bool throwWhenDuplicatePrimaryKey)
{
for (var j = 0; j < TabFilePaths.Length; j++)
{
var tabFilePath = TabFilePaths[j];
using (var tableFile = SettingModule.Get(tabFilePath, false))
{
foreach (var row in tableFile)
{
var pk = SubdirSubSubDirExample3Setting.ParsePrimaryKey(row);
SubdirSubSubDirExample3Setting setting;
if (!_dict.TryGetValue(pk, out setting))
{
setting = new SubdirSubSubDirExample3Setting(row);
_dict[setting.Id] = setting;
}
else
{
if (throwWhenDuplicatePrimaryKey) throw new System.Exception(string.Format("DuplicateKey, Class: {0}, File: {1}, Key: {2}", this.GetType().Name, tabFilePath, pk));
else setting.Reload(row);
}
}
}
}
if (OnReload != null)
{
OnReload();
}
}
/// <summary> /// Get the singleton /// </summary> /// <returns></returns> public static SubdirSubSubDirExample3Settings GetInstance() { if (_instance == null) { _instance = new SubdirSubSubDirExample3Settings(); _instance._ReloadAll(true); #if UNITY_EDITOR if (SettingModule.IsFileSystemMode) { for (var j = 0; j < TabFilePaths.Length; j++) { var tabFilePath = TabFilePaths[j]; SettingModule.WatchSetting(tabFilePath, (path) => { if (path.Replace("\\", "/").EndsWith(path)) { _instance.ReloadAll(); Log.LogConsole_MultiThread("Reload success! -> " + path); } }); } } #endif } return(_instance); }