| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- //
- // System.Web.SessionState.HttpSessionState
- //
- // Authors:
- // Gonzalo Paniagua Javier ([email protected])
- //
- // (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
- //
- using System;
- using System.Collections;
- using System.Collections.Specialized;
- using System.Globalization;
- using System.Threading;
- namespace System.Web.SessionState {
- public sealed class HttpSessionState : ICollection, IEnumerable
- {
- private string _id;
- private SessionDictionary _dict;
- private HttpStaticObjectsCollection _staticObjects;
- private int _timeout;
- private bool _newSession;
- private bool _isCookieless;
- private SessionStateMode _mode;
- private bool _isReadonly;
- private bool _abandoned;
- internal HttpSessionState (string id,
- SessionDictionary dict,
- HttpStaticObjectsCollection staticObjects,
- int timeout,
- bool newSession,
- bool isCookieless,
- SessionStateMode mode,
- bool isReadonly)
- {
- _id = id;
- _dict = dict;
- _staticObjects = staticObjects;
- _timeout = timeout;
- _newSession = newSession;
- _isCookieless = isCookieless;
- _mode = mode;
- _isReadonly = isReadonly;
- }
- // Compatibility with ASP
- public int CodePage
- {
- get { return 0; }
- set { }
- }
- public HttpSessionState Contents
- {
- get { return this; }
- }
- public int Count
- {
- get { return _dict.Count; }
- }
- internal bool IsAbandoned
- {
- get { return _abandoned; }
- }
- public bool IsCookieless
- {
- get { return _isCookieless; }
- }
- public bool IsNewSession
- {
- get { return _newSession; }
- }
- public bool IsReadOnly
- {
- get { return _isReadonly; }
- }
- public bool IsSynchronized
- {
- get { return false; }
- }
- public object this [string key]
- {
- get { return _dict [key]; }
- set { _dict [key] = value; }
- }
- public object this [int index]
- {
- get { return _dict [index]; }
- set {
- string key = _dict.Keys [index];
- _dict [key] = value;
- }
- }
- public NameObjectCollectionBase.KeysCollection Keys
- {
- get { return _dict.Keys; }
- }
- public int LCID
- {
- get { return Thread.CurrentThread.CurrentCulture.LCID; }
- set { Thread.CurrentThread.CurrentCulture = new CultureInfo(value); }
- }
- public SessionStateMode Mode
- {
- get { return _mode; }
- }
- public string SessionID
- {
- get { return _id; }
- }
- public HttpStaticObjectsCollection StaticObjects
- {
- get { return _staticObjects; }
- }
- public object SyncRoot
- {
- get { return this; }
- }
- public int Timeout
- {
- get { return _timeout; }
- set { _timeout = value; }
- }
- public void Abandon ()
- {
- _abandoned = true;
- }
- public void Add (string name, object value)
- {
- _dict [name] = value;
- }
- public void Clear ()
- {
- if (_dict != null)
- _dict.Clear ();
- }
-
- public void CopyTo (Array array, int index)
- {
- NameObjectCollectionBase.KeysCollection all = Keys;
- for (int i = 0; i < all.Count; i++)
- array.SetValue (_dict [all [i]], i + index);
- }
- public IEnumerator GetEnumerator ()
- {
- return _dict.GetEnumerator ();
- }
-
- public void Remove (string name)
- {
- _dict.Remove (name);
- }
- public void RemoveAll ()
- {
- _dict.Clear ();
- }
- public void RemoveAt (int index)
- {
- _dict.RemoveAt (index);
- }
- }
- }
|