2 // System.Web.SessionState.HttpSessionState
5 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 // (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
10 using System.Collections;
11 using System.Collections.Specialized;
12 using System.Globalization;
14 using System.Threading;
17 namespace System.Web.SessionState {
18 public sealed class HttpSessionState : ICollection, IEnumerable
21 private SessionDictionary _dict;
22 private HttpStaticObjectsCollection _staticObjects;
24 private bool _newSession;
25 private bool _isCookieless;
26 private SessionStateMode _mode;
27 private bool _isReadonly;
28 private bool _abandoned;
30 internal HttpSessionState (string id,
31 SessionDictionary dict,
32 HttpStaticObjectsCollection staticObjects,
36 SessionStateMode mode,
41 _staticObjects = staticObjects;
43 _newSession = newSession;
44 _isCookieless = isCookieless;
46 _isReadonly = isReadonly;
51 HttpContext current = HttpContext.Current;
53 return Encoding.Default.CodePage;
55 return current.Response.ContentEncoding.CodePage;
59 HttpContext current = HttpContext.Current;
61 current.Response.ContentEncoding = Encoding.GetEncoding (value);
65 public HttpSessionState Contents {
70 get { return _dict.Count; }
73 internal bool IsAbandoned {
74 get { return _abandoned; }
77 public bool IsCookieless {
78 get { return _isCookieless; }
81 public bool IsNewSession {
82 get { return _newSession; }
83 set { _newSession=value; }
86 public bool IsReadOnly {
87 get { return _isReadonly; }
90 public bool IsSynchronized {
94 public object this [string key] {
95 get { return _dict [key]; }
96 set { _dict [key] = value; }
99 public object this [int index] {
100 get { return _dict [index]; }
101 set { _dict [index] = value; }
104 public NameObjectCollectionBase.KeysCollection Keys {
105 get { return _dict.Keys; }
109 get { return Thread.CurrentThread.CurrentCulture.LCID; }
110 set { Thread.CurrentThread.CurrentCulture = new CultureInfo(value); }
113 public SessionStateMode Mode {
114 get { return _mode; }
117 public string SessionID {
121 public HttpStaticObjectsCollection StaticObjects {
122 get { return _staticObjects; }
125 public object SyncRoot {
130 get { return _timeout; }
133 throw new ArgumentException ("The argument to SetTimeout must be greater than 0.");
138 internal SessionDictionary SessionDictionary {
139 get { return _dict; }
142 public void Abandon ()
147 public void Add (string name, object value)
149 _dict [name] = value;
158 public void CopyTo (Array array, int index)
160 NameObjectCollectionBase.KeysCollection all = Keys;
161 for (int i = 0; i < all.Count; i++)
162 array.SetValue (all.Get(i), i + index);
165 public IEnumerator GetEnumerator ()
167 return _dict.GetEnumerator ();
170 public void Remove (string name)
175 public void RemoveAll ()
180 public void RemoveAt (int index)
182 _dict.RemoveAt (index);