TUP.AsmResolver.NET.StringsHeap.GetStringByOffset C# (CSharp) Method

GetStringByOffset() public method

Gets the string by its offset.
public GetStringByOffset ( uint offset ) : string
offset uint The offset of the string.
return string
        public string GetStringByOffset(uint offset)
        {
            string stringValue;
            if (_readStrings.TryGetValue(offset, out stringValue))
                return stringValue;

            if (_mainStream.Position > _mainStream.Length)
                throw new EndOfStreamException();

            _mainStream.Seek(offset, SeekOrigin.Begin);
            byte lastByte = 0;
            do
            {
                lastByte = _binReader.ReadByte();

            } while (lastByte != 0 && _mainStream.Position < _mainStream.Length);

            int endoffset = (int)_mainStream.Position - 1;

            _mainStream.Seek(offset, SeekOrigin.Begin);

            stringValue = Encoding.UTF8.GetString(_binReader.ReadBytes(endoffset - (int)offset), 0, endoffset - (int)offset);
            _readStrings.Add(offset, stringValue);
            return _readStrings[offset];
        }