/// <summary> /// Adds dictionary from stream without overwriting existing keys(keeps old) /// </summary> /// <param name="str">Stream (BinaryReader convertable)</param> public void Append(Stream str) { var file = new BinaryReader(str); var count = file.ReadInt32(); for (var id = 0; id < count; id++) { var key = DefString.Read(file); var value = DefString.Read(file); if (!dict.ContainsKey(key)) { dict.Add(key, value); } } }
/// <summary> /// Adds dictionary from stream with overwriting existing keys without log warnings /// </summary> /// <param name="str">Stream (BinaryReader convertable)</param> public void AddOverwrite(Stream str) { var file = new BinaryReader(str); var count = file.ReadInt32(); for (var id = 0; id < count; id++) { var key = DefString.Read(file); var value = DefString.Read(file); if (dict.ContainsKey(key)) { dict[key] = value; } else { dict.Add(key, value); } } }
public LangPack(Stream str) { var file = new BinaryReader(str); var count = file.ReadInt32(); for (var id = 0; id < count; id++) { var key = DefString.Read(file); var value = DefString.Read(file); if (dict.ContainsKey(key)) { LogManager.Post("[WARN] Duplicated key '{0}' - overwriting", key); dict[key] = value; } else { dict.Add(key, value); } } }