void ReadStringsFromBuffer(LocaleStringTableBuffer stringData) { using (var ms = new System.IO.MemoryStream(stringData.Buffer)) using (var er = new IO.EndianReader(ms, Shell.EndianFormat.Big)) { foreach (var sref in mStringReferences) { sref.ReadLanguageStrings(er); } } }
void Read(IO.BitStream s) { int count; s.Read(out count, kInfo.CountBitLength); ReferencesRead(s, count); if (HasStrings) { var string_data = new LocaleStringTableBuffer(this); s.StreamObject(string_data); ReadStringsFromBuffer(string_data); } }
void Write(IO.BitStream s) { LocaleStringTableBuffer string_data = null; if (HasStrings) { string_data = new LocaleStringTableBuffer(this); WriteStringsToBuffer(string_data); } Contract.Assert(Count <= Capacity); s.Write(mStringReferences.Count, kInfo.CountBitLength); ReferencesWrite(s); if (HasStrings) { s.StreamObject(string_data); } }
void WriteStringsToBuffer(LocaleStringTableBuffer stringData) { var pool = new Memory.Strings.StringMemoryPool(kStringPoolConfig); foreach (var sref in mStringReferences) { sref.WriteLanguageString(pool); } using (var ms = new System.IO.MemoryStream((int)pool.Size)) using (var ew = new IO.EndianWriter(ms, Shell.EndianFormat.Big)) { pool.WriteStrings(ew); stringData.Buffer = ms.ToArray(); } if (stringData.Buffer.Length > kInfo.BufferMaxSize) { throw new InvalidOperationException("Exceeded string table buffer size by (bytes): " + (stringData.Buffer.Length - kInfo.BufferMaxSize)); } }