static internal SessionDictionary Deserialize(BinaryReader reader) { SessionDictionary d = new SessionDictionary(); int count; int nullKey; String key; Object value; int i; count = reader.ReadInt32(); nullKey = reader.ReadInt32(); for (i = 0; i < count; i++) { if (i == nullKey) { key = null; } else { key = reader.ReadString(); } value = AltSerialization.ReadValueFromStream(reader); d.BaseSet(key, value); } d._dirty = false; return(d); }
void UpdateSession(string id, int timeout, SessionDictionary dict) { ((IDataParameter)updateCommand.Parameters["SessionID"]).Value = id; ((IDataParameter)updateCommand.Parameters["Expires"]).Value = DateTime.Now.AddMinutes(timeout); ((IDataParameter)updateCommand.Parameters["Timeout"]).Value = timeout; ((IDataParameter)updateCommand.Parameters["SessionData"]).Value = dict.ToByteArray(); updateCommand.ExecuteNonQuery(); }
internal SessionDictionary Clone () { SessionDictionary sess = new SessionDictionary (); int last = Count; for (int i = 0; i < last; i++) { string key = GetKey (i); sess [key] = this [key]; } return sess; }
internal InProcSessionState( SessionDictionary dict, HttpStaticObjectsCollection staticObjects, int timeout, bool isCookieless, int streamLength, bool locked, DateTime utcLockDate, int lockCookie) { Copy(dict, staticObjects, timeout, isCookieless, streamLength, locked, utcLockDate, lockCookie); }
internal static SessionDictionary Deserialize(BinaryReader r) { SessionDictionary result = new SessionDictionary(); for (int i = r.ReadInt32(); i > 0; i--) { result [r.ReadString()] = System.Web.Util.AltSerialization.Deserialize(r); } return(result); }
internal SessionDictionary Clone() { SessionDictionary sess = new SessionDictionary(); int last = Count; for (int i = 0; i < last; i++) { string key = GetKey(i); sess [key] = this [key]; } return(sess); }
void UpdateSessionWithRetry(string id, int timeout, SessionDictionary dict) { try { UpdateSession(id, timeout, dict); return; } catch { } try { DisposeConnection(); } catch { } InitializeConnection(); UpdateSession(id, timeout, dict); }
static protected SessionStateItem Deserialize( Stream stream, int lockCookie) { SessionStateItem item; int timeout; bool isCookieless; SessionDictionary dict; bool hasDict; bool hasStaticObjects; HttpStaticObjectsCollection col; Byte eof; BinaryReader reader = new BinaryReader(stream); timeout = reader.ReadInt32(); isCookieless = reader.ReadBoolean(); hasDict = reader.ReadBoolean(); hasStaticObjects = reader.ReadBoolean(); if (hasDict) { dict = SessionDictionary.Deserialize(reader); } else { dict = null; } if (hasStaticObjects) { col = HttpStaticObjectsCollection.Deserialize(reader); } else { col = null; } eof = reader.ReadByte(); Debug.Assert(eof == 0xff); item = new SessionStateItem( dict, col, timeout, isCookieless, (int)stream.Position, false, TimeSpan.Zero, lockCookie); return(item); }
internal static SessionDictionary FromByteArray(byte [] data) { SessionDictionary result = null; MemoryStream stream = null; try { stream = new MemoryStream(data); result = Deserialize(new BinaryReader(stream)); } catch { throw; } finally { if (stream != null) { stream.Close(); } } return(result); }
internal HttpSessionState (string id, SessionDictionary dict, HttpStaticObjectsCollection staticObjects, int timeout, bool newSession, bool isCookieless, SessionStateMode mode, bool isReadonly) { _id = id; _dict = dict; _staticObjects = staticObjects.Clone (); _timeout = timeout; _newSession = newSession; _isCookieless = isCookieless; _mode = mode; _isReadonly = isReadonly; }
internal HttpSessionState(string id, SessionDictionary dict, HttpStaticObjectsCollection staticObjects, int timeout, bool newSession, bool isCookieless, SessionStateMode mode, bool isReadonly) { _id = id; _dict = dict; _staticObjects = staticObjects.Clone(); _timeout = timeout; _newSession = newSession; _isCookieless = isCookieless; _mode = mode; _isReadonly = isReadonly; }
internal void Copy( SessionDictionary dict, HttpStaticObjectsCollection staticObjects, int timeout, bool isCookieless, int streamLength, bool locked, DateTime utcLockDate, int lockCookie) { this.dict = dict; this.staticObjects = staticObjects; this.timeout = timeout; this.isCookieless = isCookieless; this.streamLength = streamLength; this.locked = locked; this.utcLockDate = utcLockDate; this.lockCookie = lockCookie; }
internal SessionStateItem( SessionDictionary dict, HttpStaticObjectsCollection staticObjects, int timeout, bool isCookieless, int streamLength, bool locked, TimeSpan lockAge, int lockCookie) { this.dict = dict; this.staticObjects = staticObjects; this.timeout = timeout; this.isCookieless = isCookieless; this.streamLength = streamLength; this.locked = locked; this.lockAge = lockAge; this.lockCookie = lockCookie; }
public void UpdateHandler(HttpContext context, SessionStateModule module) { HttpSessionState session = context.Session; if (session == null || session.IsReadOnly) { return; } string id = session.SessionID; if (!session._abandoned) { SessionDictionary dict = session.SessionDictionary; UpdateSessionWithRetry(id, session.Timeout, dict); } else { DeleteSessionWithRetry(id); } }
HttpSessionState SelectSession(string id, bool read_only) { HttpSessionState session = null; using (IDataReader reader = GetReaderWithRetry(id)) { if (!reader.Read()) { return(null); } SessionDictionary dict; HttpStaticObjectsCollection sobjs; int timeout; dict = SessionDictionary.FromByteArray(ReadBytes(reader, reader.FieldCount - 1)); sobjs = HttpStaticObjectsCollection.FromByteArray(ReadBytes(reader, reader.FieldCount - 2)); // try to support as many DBs/int types as possible timeout = Convert.ToInt32(reader.GetValue(reader.FieldCount - 3)); session = new HttpSessionState(id, dict, sobjs, timeout, false, config.CookieLess, SessionStateMode.SQLServer, read_only); return(session); } }
void UpdateSessionWithRetry (string id, int timeout, SessionDictionary dict) { try { UpdateSession (id, timeout, dict); return; } catch { } try { DisposeConnection (); } catch { } InitializeConnection (); UpdateSession (id, timeout, dict); }
internal static SessionDictionary Deserialize (BinaryReader r) { SessionDictionary result = new SessionDictionary (); for (int i = r.ReadInt32(); i > 0; i--) result [r.ReadString ()] = System.Web.Util.AltSerialization.Deserialize (r); return result; }
internal static SessionDictionary Deserialize (BinaryReader r) { SessionDictionary result = new SessionDictionary (); for (int i = r.ReadInt32 (); i > 0; i--) { string key = r.ReadString (); int index = r.ReadInt32 (); if (index == System.Web.Util.AltSerialization.NullIndex) result [key] = null; else result [key] = System.Web.Util.AltSerialization.DeserializeFromIndex (index, r); } return result; }
void UpdateSession (string id, int timeout, SessionDictionary dict) { ((IDataParameter)updateCommand.Parameters["SessionID"]).Value = id; ((IDataParameter)updateCommand.Parameters["Expires"]).Value = DateTime.Now.AddMinutes (timeout); ((IDataParameter)updateCommand.Parameters["Timeout"]).Value = timeout; ((IDataParameter)updateCommand.Parameters["SessionData"]).Value = dict.ToByteArray (); updateCommand.ExecuteNonQuery (); }
private void UpdateSession (string id, SessionDictionary dict) { IDbCommand command = cnc.CreateCommand (); IDataParameterCollection param; string update = "UPDATE ASPStateTempSessions SET " + "SessionData = :SessionData WHERE SessionId = :SessionID"; command.CommandText = update; param = command.Parameters; param.Add (CreateParam (command, DbType.String, ":SessionID", id)); param.Add (CreateParam (command, DbType.Binary, ":SessionData", dict.ToByteArray ())); command.ExecuteNonQuery (); }
public HttpSessionState UpdateContext (HttpContext context, SessionStateModule module, bool required, bool read_only, ref bool isNew) { if (!required) return null; StateServerItem item = null; HttpSessionState session = null; SessionDictionary dict = null; HttpStaticObjectsCollection sobjs = null; string id = GetId (context); if (id != null) { item = state_server.Get (id); if (item != null) { dict = SessionDictionary.FromByteArray (item.DictionaryData); sobjs = HttpStaticObjectsCollection.FromByteArray (item.StaticObjectsData); session = new HttpSessionState (id, dict, HttpApplicationFactory.ApplicationState.SessionObjects, config.Timeout, false, config.CookieLess, SessionStateMode.StateServer, read_only); return session; } } id = SessionId.Create (module.Rng); dict = new SessionDictionary (); sobjs = HttpApplicationFactory.ApplicationState.SessionObjects; item = new StateServerItem (dict.ToByteArray (), sobjs.ToByteArray (), config.Timeout); state_server.Insert (id, item); session = new HttpSessionState (id, dict, sobjs, config.Timeout, true, config.CookieLess, SessionStateMode.StateServer, read_only); isNew = true; return session; }