public static void SaveData(this ISaveAsJson source, JSON mainData) { JSON saveData = source.Save(); saveData.AddOrReplace(VersionKey, source.Version); mainData.Add(source.Key, saveData); }
public static bool IsOldVersion(this ISaveAsJson source, JSON data) { if (!data.ContainsKey(VersionKey)) { throw new KeyNotFoundException($"El archivo NO contiene la VersionKey '{VersionKey}' para el tipo de archivo: {source.GetType()}"); } int fileVersion = data.GetInt(VersionKey); return(fileVersion < source.Version); }
public static void LoadData(this ISaveAsJson source, JSON mainData) { if (!mainData.ContainsKey(source.Key)) { return; } JSON loadData = mainData.GetJSON(source.Key); if (!mainData.ContainsKey(source.Key)) { return; } if (IsOldVersion(source, loadData)) { source.UpdateSaveData(loadData); } source.Load(loadData); }
public static void Unregister(ISaveAsJson target) => Instance.saveAsJsonModule.Unregister(target);
public void Unregister(ISaveAsJson saveAsJson) => saveAsJsonModule.Unregister(saveAsJson);
public void Register(ISaveAsJson saveAsJson) => saveAsJsonModule.Register(saveAsJson);
public void Unregister(ISaveAsJson target) { OnLoad -= target.LoadData; OnSave -= target.SaveData; }
public void Register(ISaveAsJson target) { OnLoad += target.LoadData; OnSave += target.SaveData; }