(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.Web / System.Web / HttpApplicationState.cs
blob17f0968fe09e3df8310a99ca8949d91c30e92d47
1 //
2 // System.Web.HttpApplicationState
3 //
4 // Author:
5 // Patrik Torstensson
6 //
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 using System;
29 using System.Threading;
30 using System.Web;
31 using System.Collections.Specialized;
33 namespace System.Web
36 public sealed class HttpApplicationState : NameObjectCollectionBase
38 private HttpStaticObjectsCollection _AppObjects;
39 private HttpStaticObjectsCollection _SessionObjects;
41 private ReaderWriterLock _Lock;
43 internal HttpApplicationState ()
45 _AppObjects = new HttpStaticObjectsCollection ();
46 _SessionObjects = new HttpStaticObjectsCollection ();
47 _Lock = new ReaderWriterLock ();
50 internal HttpApplicationState (HttpStaticObjectsCollection AppObj,
51 HttpStaticObjectsCollection SessionObj)
53 if (null != AppObj)
55 _AppObjects = AppObj;
57 else
59 _AppObjects = new HttpStaticObjectsCollection ();
62 if (null != SessionObj)
64 _SessionObjects = SessionObj;
66 else
68 _SessionObjects = new HttpStaticObjectsCollection ();
70 _Lock = new ReaderWriterLock ();
73 public void Add (string name, object value)
75 _Lock.AcquireWriterLock (-1);
76 try
78 BaseAdd (name, value);
80 finally
82 _Lock.ReleaseWriterLock ();
86 public void Clear ()
88 _Lock.AcquireWriterLock (-1);
89 try
91 BaseClear ();
93 finally
95 _Lock.ReleaseWriterLock ();
99 public object Get (string name)
101 object ret = null;
103 _Lock.AcquireReaderLock (-1);
104 try
106 ret = BaseGet (name);
108 finally
110 _Lock.ReleaseReaderLock ();
113 return ret;
116 public object Get (int index)
118 object ret = null;
120 _Lock.AcquireReaderLock (-1);
121 try
123 ret = BaseGet (index);
125 finally
127 _Lock.ReleaseReaderLock ();
130 return ret;
133 public string GetKey (int index)
135 string ret = null;
137 _Lock.AcquireReaderLock (-1);
138 try
140 ret = BaseGetKey (index);
142 finally
144 _Lock.ReleaseReaderLock ();
147 return ret;
150 public void Lock ()
152 _Lock.AcquireWriterLock (-1);
155 public void Remove (string name)
157 _Lock.AcquireWriterLock (-1);
158 try
160 BaseRemove (name);
162 finally
164 _Lock.ReleaseWriterLock ();
168 public void RemoveAll ()
170 Clear ();
173 public void RemoveAt (int index)
175 _Lock.AcquireWriterLock (-1);
176 try
178 BaseRemoveAt (index);
180 finally
182 _Lock.ReleaseWriterLock ();
186 public void Set (string name, object value)
188 _Lock.AcquireWriterLock (-1);
189 try
191 BaseSet (name, value);
193 finally
195 _Lock.ReleaseWriterLock ();
199 public void UnLock ()
201 _Lock.ReleaseWriterLock ();
204 public string [] AllKeys
206 get
208 string [] ret = null;
210 _Lock.AcquireReaderLock (-1);
211 try
213 ret = BaseGetAllKeys ();
215 finally
217 _Lock.ReleaseReaderLock ();
220 return ret;
224 public HttpApplicationState Contents
226 get { return this; }
229 public override int Count
231 get
233 int ret = 0;
235 _Lock.AcquireReaderLock (-1);
236 try
238 ret = base.Count;
240 finally
242 _Lock.ReleaseReaderLock ();
245 return ret;
249 public object this [string name]
251 get { return Get (name); }
252 set { Set (name, value); }
255 public object this [int index]
257 get { return Get (index); }
260 // ASP Session based objects
261 internal HttpStaticObjectsCollection SessionObjects
263 get { return _SessionObjects; }
266 // ASP App based objects
267 public HttpStaticObjectsCollection StaticObjects
269 get { return _AppObjects; }