setting all protected methods on WizardStepPage as virtual
[castle.git] / MonoRail / Castle.MonoRail.Framework / Adapters / SessionAdapter.cs
blob428644d8b495a8d0837102996f283fd2b337c5dc
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.MonoRail.Framework.Adapters
17 using System;
18 using System.Collections;
19 using System.Web.SessionState;
21 /// <summary>
22 /// Adapts the ASP.Net session as a simple dictionary for MonoRail
23 /// </summary>
24 public class SessionAdapter : MarshalByRefObject, IDictionary
26 private HttpSessionState _session;
28 /// <summary>
29 /// Initializes a new instance of the <see cref="SessionAdapter"/> class.
30 /// </summary>
31 /// <param name="session">The session.</param>
32 public SessionAdapter( HttpSessionState session )
34 _session = session;
37 /// <summary>
38 /// Returns an <see cref="T:System.Collections.IDictionaryEnumerator"></see> object for the <see cref="T:System.Collections.IDictionary"></see> object.
39 /// </summary>
40 /// <returns>
41 /// An <see cref="T:System.Collections.IDictionaryEnumerator"></see> object for the <see cref="T:System.Collections.IDictionary"></see> object.
42 /// </returns>
43 IDictionaryEnumerator IDictionary.GetEnumerator()
45 throw new NotImplementedException();
48 /// <summary>
49 /// Gets an <see cref="T:System.Collections.ICollection"></see> object containing the keys of the <see cref="T:System.Collections.IDictionary"></see> object.
50 /// </summary>
51 /// <value></value>
52 /// <returns>An <see cref="T:System.Collections.ICollection"></see> object containing the keys of the <see cref="T:System.Collections.IDictionary"></see> object.</returns>
53 public ICollection Keys
55 get { return _session.Keys; }
58 /// <summary>
59 /// Copies the elements of the <see cref="T:System.Collections.ICollection"></see> to an <see cref="T:System.Array"></see>, starting at a particular <see cref="T:System.Array"></see> index.
60 /// </summary>
61 /// <param name="array">The one-dimensional <see cref="T:System.Array"></see> that is the destination of the elements copied from <see cref="T:System.Collections.ICollection"></see>. The <see cref="T:System.Array"></see> must have zero-based indexing.</param>
62 /// <param name="index">The zero-based index in array at which copying begins.</param>
63 /// <exception cref="T:System.ArgumentNullException">array is null. </exception>
64 /// <exception cref="T:System.ArgumentOutOfRangeException">index is less than zero. </exception>
65 /// <exception cref="T:System.ArgumentException">array is multidimensional.-or- index is equal to or greater than the length of array.-or- The number of elements in the source <see cref="T:System.Collections.ICollection"></see> is greater than the available space from index to the end of the destination array. </exception>
66 /// <exception cref="T:System.InvalidCastException">The type of the source <see cref="T:System.Collections.ICollection"></see> cannot be cast automatically to the type of the destination array. </exception>
67 public void CopyTo(Array array, int index)
69 throw new NotImplementedException();
72 /// <summary>
73 /// Gets the number of elements contained in the <see cref="T:System.Collections.ICollection"></see>.
74 /// </summary>
75 /// <value></value>
76 /// <returns>The number of elements contained in the <see cref="T:System.Collections.ICollection"></see>.</returns>
77 public int Count
79 get { return _session.Count; }
82 /// <summary>
83 /// Gets an object that can be used to synchronize access to the <see cref="T:System.Collections.ICollection"></see>.
84 /// </summary>
85 /// <value></value>
86 /// <returns>An object that can be used to synchronize access to the <see cref="T:System.Collections.ICollection"></see>.</returns>
87 public object SyncRoot
89 get { return _session.SyncRoot; }
92 /// <summary>
93 /// Gets a value indicating whether access to the <see cref="T:System.Collections.ICollection"></see> is synchronized (thread safe).
94 /// </summary>
95 /// <value></value>
96 /// <returns>true if access to the <see cref="T:System.Collections.ICollection"></see> is synchronized (thread safe); otherwise, false.</returns>
97 public bool IsSynchronized
99 get { return _session.IsSynchronized; }
102 /// <summary>
103 /// Returns an enumerator that iterates through a collection.
104 /// </summary>
105 /// <returns>
106 /// An <see cref="T:System.Collections.IEnumerator"></see> object that can be used to iterate through the collection.
107 /// </returns>
108 public IEnumerator GetEnumerator()
110 return _session.GetEnumerator();
113 /// <summary>
114 /// Determines whether the <see cref="T:System.Collections.IDictionary"></see> object contains an element with the specified key.
115 /// </summary>
116 /// <param name="key">The key to locate in the <see cref="T:System.Collections.IDictionary"></see> object.</param>
117 /// <returns>
118 /// true if the <see cref="T:System.Collections.IDictionary"></see> contains an element with the key; otherwise, false.
119 /// </returns>
120 /// <exception cref="T:System.ArgumentNullException">key is null. </exception>
121 public bool Contains( object key )
123 return _session[ (String)key ] != null;
126 /// <summary>
127 /// Adds an element with the provided key and value to the <see cref="T:System.Collections.IDictionary"></see> object.
128 /// </summary>
129 /// <param name="key">The <see cref="T:System.Object"></see> to use as the key of the element to add.</param>
130 /// <param name="value">The <see cref="T:System.Object"></see> to use as the value of the element to add.</param>
131 /// <exception cref="T:System.ArgumentException">An element with the same key already exists in the <see cref="T:System.Collections.IDictionary"></see> object. </exception>
132 /// <exception cref="T:System.ArgumentNullException">key is null. </exception>
133 /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.IDictionary"></see> is read-only.-or- The <see cref="T:System.Collections.IDictionary"></see> has a fixed size. </exception>
134 public void Add( object key, object value )
136 _session.Add( (String)key, value );
139 /// <summary>
140 /// Removes all elements from the <see cref="T:System.Collections.IDictionary"></see> object.
141 /// </summary>
142 /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.IDictionary"></see> object is read-only. </exception>
143 public void Clear()
145 _session.Clear();
148 /// <summary>
149 /// Removes the element with the specified key from the <see cref="T:System.Collections.IDictionary"></see> object.
150 /// </summary>
151 /// <param name="key">The key of the element to remove.</param>
152 /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.IDictionary"></see> object is read-only.-or- The <see cref="T:System.Collections.IDictionary"></see> has a fixed size. </exception>
153 /// <exception cref="T:System.ArgumentNullException">key is null. </exception>
154 public void Remove( object key )
156 _session.Remove( (String)key );
159 /// <summary>
160 /// Gets an <see cref="T:System.Collections.ICollection"></see> object containing the values in the <see cref="T:System.Collections.IDictionary"></see> object.
161 /// </summary>
162 /// <value></value>
163 /// <returns>An <see cref="T:System.Collections.ICollection"></see> object containing the values in the <see cref="T:System.Collections.IDictionary"></see> object.</returns>
164 public ICollection Values
166 get { throw new NotImplementedException(); }
169 /// <summary>
170 /// Gets a value indicating whether the <see cref="T:System.Collections.IDictionary"></see> object is read-only.
171 /// </summary>
172 /// <value></value>
173 /// <returns>true if the <see cref="T:System.Collections.IDictionary"></see> object is read-only; otherwise, false.</returns>
174 public bool IsReadOnly
176 get { return _session.IsReadOnly; }
179 /// <summary>
180 /// Gets a value indicating whether the <see cref="T:System.Collections.IDictionary"></see> object has a fixed size.
181 /// </summary>
182 /// <value></value>
183 /// <returns>true if the <see cref="T:System.Collections.IDictionary"></see> object has a fixed size; otherwise, false.</returns>
184 public bool IsFixedSize
186 get { return false; }
189 /// <summary>
190 /// Gets or sets the <see cref="System.Object"/> with the specified key.
191 /// </summary>
192 /// <value></value>
193 public object this[ object key ]
195 get { return _session[ (String)key ]; }
198 _session[ (String)key ] = value;