2 // System.Web.Compilation.SessionStateItemCollection
5 // Marek Habersack (grendello@gmail.com)
7 // (C) 2006 Marek Habersack
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System.Collections;
32 using System.Collections.Generic;
33 using System.Collections.Specialized;
35 using System.Web.Util;
37 namespace System.Web.SessionState
39 public sealed class SessionStateItemCollection : NameObjectCollectionBase, ISessionStateItemCollection, ICollection, IEnumerable
43 static bool IsMutable (object o)
45 return (o != null && Type.GetTypeCode(o.GetType()) == TypeCode.Object);
48 public SessionStateItemCollection ()
52 internal SessionStateItemCollection (int capacity)
58 get { return is_dirty; }
59 set { is_dirty = value; }
62 public object this [int index] {
64 object o = BaseGet (index);
71 BaseSet (index, value);
76 public object this [string name] {
78 object o = BaseGet (name);
85 BaseSet (name, value);
90 // Todo: why override this?
91 public override KeysCollection Keys {
92 get { return base.Keys; }
103 public static SessionStateItemCollection Deserialize (BinaryReader reader)
105 int i = reader.ReadInt32 ();
106 SessionStateItemCollection ret = new SessionStateItemCollection (i);
\r
108 ret [reader.ReadString ()] =
\r
109 System.Web.Util.AltSerialization.Deserialize (reader);
114 public void Serialize (BinaryWriter writer) {
\r
115 writer.Write (Count);
\r
116 foreach (string key in base.Keys) {
\r
117 writer.Write (key);
\r
118 System.Web.Util.AltSerialization.Serialize (writer, BaseGet (key));
\r
122 // Todo: why override this?
123 public override IEnumerator GetEnumerator ()
125 return base.GetEnumerator ();
128 public void Remove (string name)
134 public void RemoveAt (int index)
136 BaseRemoveAt (index);