public void AddSession(string sessionId, string paramName, object value) { HttpSessionStateBase session; if (!Sessions.TryGetValue(sessionId, out session)) { session = new HttpSessionStateSimulator(sessionId); Sessions.Add(sessionId, session); } session[paramName] = value; }
private static HttpListenerContextSimulator Wrap(HttpListenerContext listenerContext, IDictionary <string, HttpSessionStateBase> sessions) { HttpSessionStateBase session; var sessionCookie = listenerContext.Request.Cookies["ASP.NET_SessionId"]; if (sessionCookie == null) { session = new HttpSessionStateSimulator(); } else if (!sessions.TryGetValue(sessionCookie.Value, out session)) { session = new HttpSessionStateSimulator(sessionCookie.Value); sessions.Add(sessionCookie.Value, session); } return(new HttpListenerContextSimulator(listenerContext, session)); }