本文整理汇总了C#中System.Web.SessionState.SessionStateItemCollection.BaseGetKey方法的典型用法代码示例。如果您正苦于以下问题:C# SessionStateItemCollection.BaseGetKey方法的具体用法?C# SessionStateItemCollection.BaseGetKey怎么用?C# SessionStateItemCollection.BaseGetKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.SessionState.SessionStateItemCollection
的用法示例。
在下文中一共展示了SessionStateItemCollection.BaseGetKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deserialize
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;
}
示例2: Deserialize
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;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:42,代码来源:SessionStateItemCollection.cs