public static SessionStateItemCollection Deserialize(BinaryReader reader) { SessionStateItemCollection items = new SessionStateItemCollection(); int count = reader.ReadInt32(); if (count > 0) { int num3; int num2 = reader.ReadInt32(); items._serializedItems = new KeyedCollection(count); for (num3 = 0; num3 < count; num3++) { string str; if (num3 == num2) { str = null; } else { str = reader.ReadString(); } items.BaseSet(str, null); } int dataLength = reader.ReadInt32(); items._serializedItems[items.BaseGetKey(0)] = new SerializedItemPosition(0, dataLength); int num5 = 0; for (num3 = 1; num3 < count; num3++) { num5 = reader.ReadInt32(); items._serializedItems[items.BaseGetKey(num3)] = new SerializedItemPosition(dataLength, num5 - dataLength); dataLength = num5; } items._iLastOffset = dataLength; byte[] buffer = new byte[items._iLastOffset]; if (reader.BaseStream.Read(buffer, 0, items._iLastOffset) != items._iLastOffset) { throw new HttpException(System.Web.SR.GetString("Invalid_session_state")); } items._stream = new MemoryStream(buffer); } items._dirty = false; return(items); }
public static SessionStateItemCollection Deserialize(BinaryReader reader) { SessionStateItemCollection d = new SessionStateItemCollection(); int count; int nullKey; String key; int i; byte[] buffer; count = reader.ReadInt32(); if (count > 0) { nullKey = reader.ReadInt32(); d._serializedItems = new KeyedCollection(count); // First, deserialize all the keys for (i = 0; i < count; i++) { if (i == nullKey) { key = null; } else { key = reader.ReadString(); } // Need to set them with null value first, so that // the order of them items is correct. d.BaseSet(key, null); } // Next, deserialize all the offsets // First offset will be 0, and the data length will be the first read offset int offset0 = reader.ReadInt32(); d._serializedItems[d.BaseGetKey(0)] = new SerializedItemPosition(0, offset0); int offset1 = 0; for (i = 1; i < count; i++) { offset1 = reader.ReadInt32(); d._serializedItems[d.BaseGetKey(i)] = new SerializedItemPosition(offset0, offset1 - offset0); offset0 = offset1; } // d._iLastOffset = offset0; Debug.Trace("SessionStateItemCollection", "Deserialize: _iLastOffset= " + d._iLastOffset); // _iLastOffset is the first byte past the last item, which equals // the total length of all serialized data buffer = new byte[d._iLastOffset]; int bytesRead = reader.BaseStream.Read(buffer, 0, d._iLastOffset); if (bytesRead != d._iLastOffset) { throw new HttpException(SR.GetString(SR.Invalid_session_state)); } d._stream = new MemoryStream(buffer); } #if DBG Debug.Assert(reader.ReadByte() == 0xff); #endif d._dirty = false; return(d); }
public static SessionStateItemCollection Deserialize(BinaryReader reader) { SessionStateItemCollection d = new SessionStateItemCollection(); int count; int nullKey; String key; int i; byte[] buffer; count = reader.ReadInt32(); if (count > 0) { nullKey = reader.ReadInt32(); d._serializedItems = new KeyedCollection(count); // First, deserialize all the keys for (i = 0; i < count; i++) { if (i == nullKey) { key = null; } else { key = reader.ReadString(); } // Need to set them with null value first, so that // the order of them items is correct. d.BaseSet(key, null); } // Next, deserialize all the offsets // First offset will be 0, and the data length will be the first read offset int offset0 = reader.ReadInt32(); d._serializedItems[d.BaseGetKey(0)] = new SerializedItemPosition(0, offset0); int offset1 = 0; for (i = 1; i < count; i++) { offset1 = reader.ReadInt32(); d._serializedItems[d.BaseGetKey(i)] = new SerializedItemPosition(offset0, offset1 - offset0); offset0 = offset1; } // d._iLastOffset = offset0; Debug.Trace("SessionStateItemCollection", "Deserialize: _iLastOffset= " + d._iLastOffset); // _iLastOffset is the first byte past the last item, which equals // the total length of all serialized data buffer = new byte[d._iLastOffset]; int bytesRead = reader.BaseStream.Read(buffer, 0, d._iLastOffset); if (bytesRead != d._iLastOffset) { throw new HttpException(SR.GetString(SR.Invalid_session_state)); } d._stream = new MemoryStream(buffer); } #if DBG Debug.Assert(reader.ReadByte() == 0xff); #endif d._dirty = false; return d; }
public static SessionStateItemCollection Deserialize(BinaryReader reader) { SessionStateItemCollection items = new SessionStateItemCollection(); int count = reader.ReadInt32(); if (count > 0) { int num3; int num2 = reader.ReadInt32(); items._serializedItems = new KeyedCollection(count); for (num3 = 0; num3 < count; num3++) { string str; if (num3 == num2) { str = null; } else { str = reader.ReadString(); } items.BaseSet(str, null); } int dataLength = reader.ReadInt32(); items._serializedItems[items.BaseGetKey(0)] = new SerializedItemPosition(0, dataLength); int num5 = 0; for (num3 = 1; num3 < count; num3++) { num5 = reader.ReadInt32(); items._serializedItems[items.BaseGetKey(num3)] = new SerializedItemPosition(dataLength, num5 - dataLength); dataLength = num5; } items._iLastOffset = dataLength; byte[] buffer = new byte[items._iLastOffset]; if (reader.BaseStream.Read(buffer, 0, items._iLastOffset) != items._iLastOffset) { throw new HttpException(System.Web.SR.GetString("Invalid_session_state")); } items._stream = new MemoryStream(buffer); } items._dirty = false; return items; }