KeyValuePair <string, long> _bytesToPair(byte[] bytes) { MemoryStream ms = new MemoryStream(bytes); string str = ms.ReadString(); long val = ms.ReadInt64(); return(new KeyValuePair <string, long>(str, val)); }
public void ReadInt64() { Int64 testValue = 4096; using( var stream = new MemoryStream() ) { var bytes = BitConverter.GetBytes( testValue ); stream.Write( bytes, 0, bytes.Length ); stream.Seek( 0, SeekOrigin.Begin ); var value = stream.ReadInt64(); Assert.AreEqual( value, testValue ); } }
public void Read(MemoryStream ms) { base.Read(ms, "MCNK"); flags = (uint) ms.ReadInt32(); indexX = (uint)ms.ReadInt32(); indexY = (uint)ms.ReadInt32(); numLayers = (uint)ms.ReadInt32(); numDoodads = (uint)ms.ReadInt32(); mcvtOff = (uint)ms.ReadInt32(); mcnrOff = (uint)ms.ReadInt32(); mclyOff = (uint)ms.ReadInt32(); mcrfOff = (uint)ms.ReadInt32(); mcalOff = (uint)ms.ReadInt32(); mcalSize = (uint)ms.ReadInt32(); mcshOff = (uint)ms.ReadInt32(); mcshSize = (uint)ms.ReadInt32(); areaId = (uint)ms.ReadInt32(); numWmos = (uint)ms.ReadInt32(); holes = (uint)ms.ReadInt32(); texmap0 = (ulong)ms.ReadInt64(); texmap1 = (ulong)ms.ReadInt64(); predTex = (uint)ms.ReadInt32(); noEffectDoodad = (uint)ms.ReadInt32(); msceOff = (uint)ms.ReadInt32(); numSoundEmitters = (uint)ms.ReadInt32(); mclqOff = (uint)ms.ReadInt32(); mclqSize = (uint)ms.ReadInt32(); float x = ms.ReadFloat(); float y = ms.ReadFloat(); float z = ms.ReadFloat(); position = new Vector3(x, y, z); mccvOff = (uint)ms.ReadInt32(); ms.Read(pad, 0, pad.Length); }
public uint Read(MemoryStream ms, long data_offset = 0) { long save_point; infos_offset = (uint)ms.ReadInt32(); numLayers = (uint)ms.ReadInt32(); renderMap_offset = (uint)ms.ReadInt32(); save_point = ms.Position; ms.Position = data_offset + infos_offset; if (infos_offset != 0 && numLayers != 0) { for (int i = 0; i < numLayers; i++) { Information_s info = new Information_s(); info.Read(ms, data_offset); infos.Add(info); } } if (renderMap_offset != 0) { ms.Position = data_offset + renderMap_offset; renderMap = (ulong)ms.ReadInt64(); } ms.Position = save_point; return 0; }