internal virtual void ClearBuffers() { if (HeaderUnpacker != null) { try { HeaderUnpacker.Dispose(); } catch (InvalidMessagePackStreamException) { // Handles cleanup for corruppted stream. } HeaderUnpacker = null; } if (RootUnpacker != null) { try { RootUnpacker.Dispose(); } catch (InvalidMessagePackStreamException) { // Handles cleanup for corruppted stream. } RootUnpacker = null; } if (UnpackingBuffer != null) { TruncateUsedReceivedData(); } }
public IDictionary <K, V> GetMapt <K, V>(int index) { MemoryStream s = new MemoryStream(buff); Unpacker _unpacker = Unpacker.Create(s); for (int i = 0; i < index; i++) { _unpacker.Skip(); } long len = 0; if (!_unpacker.ReadMapLength(out len)) { return(null); } IDictionary <K, V> dict = new Dictionary <K, V>(); for (int i = 0; i < len; i++) { dict.Add(_unpacker.Unpack <K>(), _unpacker.Unpack <V>()); } _unpacker.Dispose(); s.Close(); return(dict); }
public T[] GetArray <T>(int index) { MemoryStream s = new MemoryStream(buff); Unpacker _unpacker = Unpacker.Create(s); for (int i = 0; i < index; i++) { _unpacker.Skip(); } long len = 0; if (!_unpacker.ReadArrayLength(out len)) { return(null); } T[] ts = new T[len]; for (int i = 0; i < len; i++) { ts[i] = _unpacker.Unpack <T>(); } _unpacker.Dispose(); s.Close(); return(ts); }
public void Close() { unpacker.Dispose(); if (stream.CanRead) { stream.Close(); } }
protected void EndState(JsonToken state) { mReader.SetToken(state); mReader.mState = this.mPreviousState; mUnpacker.Dispose(); }
public T Get <T>(int index) { MemoryStream s = new MemoryStream(buff); Unpacker _unpacker = Unpacker.Create(s); for (int i = 0; i < index; i++) { _unpacker.Skip(); } T t = _unpacker.Unpack <T>(); _unpacker.Dispose(); s.Close(); return(t); }