public void UpdateInternal(CustomModTranslationFile oldFile, CustomModTranslationFile newFile, IUpdateLogger logger) { var oldEntries = oldFile.Translations; var newEntries = newFile.Translations; foreach (var newEntryKey in newEntries.Keys) { if (oldEntries.Keys.Contains(newEntryKey)) { var o = oldEntries[newEntryKey]; var n = newEntries[newEntryKey]; if (o.Origin != n.Origin) { logger.Change($"{newEntryKey}\r\n[Old: \"{o.Origin}\"]\r\n => \r\n[New: \"{n.Origin}\"]\r\n"); o.Origin = n.Origin; o.Translation = n.Translation; } } else { logger.Add($"[{newEntryKey}]"); var entry = newEntries[newEntryKey]; oldEntries.Add(newEntryKey, entry); } } var removed = oldEntries.Keys.Where(k => !newEntries.ContainsKey(k)); foreach (var r in removed) { logger.Remove($"[{r}]"); } }
internal void UpdateEntry(string key, IEntry oldEntry, IEntry newEntry, IUpdateLogger logger) { foreach (var prop in oldEntry.GetType().ModTranslationProp()) { var o = prop.GetValue(oldEntry) as BaseEntry; var n = prop.GetValue(newEntry) as BaseEntry; if (o.Origin != n.Origin) { logger.Change($"{key}'s {prop.Name}\r\n[Old: \"{o.Origin}\"]\r\n => \r\n[New: \"{n.Origin}\"]\r\n"); o.Origin = n.Origin; } } }
public void UpdateInternal(LdstrFile oldFile, LdstrFile newFile, IUpdateLogger logger) { var oldEntries = oldFile.LdstrEntries; var newEntries = newFile.LdstrEntries; foreach (var newEntryKey in newEntries.Keys) { if (oldEntries.Keys.Contains(newEntryKey)) { var o = oldEntries[newEntryKey]; var n = newEntries[newEntryKey]; foreach (var newIns in n.Instructions) { if (o.Instructions.Exists(oi => oi.Origin == newIns.Origin)) { continue; } o.Instructions.Add(newIns); logger.Change($"New instruction of {newEntryKey}: [{newIns}]"); } } else { logger.Add($"[{newEntryKey}]"); var entry = newEntries[newEntryKey]; oldEntries.Add(newEntryKey, entry); } } var removed = oldEntries.Keys.Where(k => !newEntries.ContainsKey(k)); foreach (var r in removed) { logger.Remove($"[{r}]"); } }