- Implemented support for view component caching. Just use the attribute
[castle.git] / MonoRail / Castle.MonoRail.Framework / Internal / ResourceDictionary.cs
blobb99dfbfe6fbd7246061ffedf762648073826332d
1 // Copyright 2004-2007 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.Internal
17 using System;
18 using System.Collections;
19 using System.Collections.Specialized;
21 /// <summary>
22 /// Simple strong typed dictionary for IResource instances.
23 /// </summary>
24 public class ResourceDictionary : ICollection
26 private HybridDictionary map = new HybridDictionary(true);
28 /// <summary>
29 /// Adds the specified key.
30 /// </summary>
31 /// <param name="key">The key.</param>
32 /// <param name="resource">The resource.</param>
33 public void Add(object key, IResource resource)
35 map.Add(key, resource);
38 /// <summary>
39 /// Gets or sets the <see cref="Castle.MonoRail.Framework.IResource"/> with the specified key.
40 /// </summary>
41 /// <value></value>
42 public IResource this[object key]
44 get { return map[key] as IResource; }
45 set { map[key] = value; }
48 /// <summary>
49 /// Gets the number of elements contained in the <see cref="T:System.Collections.ICollection"></see>.
50 /// </summary>
51 /// <value></value>
52 /// <returns>The number of elements contained in the <see cref="T:System.Collections.ICollection"></see>.</returns>
53 public int Count
55 get { return map.Count; }
58 /// <summary>
59 /// Removes the specified key.
60 /// </summary>
61 /// <param name="key">The key.</param>
62 public void Remove(object key)
64 map.Remove(key);
67 /// <summary>
68 /// Determines whether the resource contains the specified key.
69 /// </summary>
70 /// <param name="key">The key.</param>
71 /// <returns>
72 /// <c>true</c> if the resource contains it; otherwise, <c>false</c>.
73 /// </returns>
74 public bool Contains(object key)
76 return map.Contains(key);
79 /// <summary>
80 /// Clears this instance.
81 /// </summary>
82 public void Clear()
84 map.Clear();
87 /// <summary>
88 /// Gets the values.
89 /// </summary>
90 /// <value>The values.</value>
91 public ICollection Values
93 get { return map.Values; }
96 /// <summary>
97 /// Gets the keys.
98 /// </summary>
99 /// <value>The keys.</value>
100 public ICollection Keys
102 get { return map.Keys; }
105 #region ICollection Members
107 /// <summary>
108 /// Gets a value indicating whether access to the <see cref="T:System.Collections.ICollection"></see> is synchronized (thread safe).
109 /// </summary>
110 /// <value></value>
111 /// <returns>true if access to the <see cref="T:System.Collections.ICollection"></see> is synchronized (thread safe); otherwise, false.</returns>
112 public bool IsSynchronized
114 get { return map.IsSynchronized; }
117 /// <summary>
118 /// 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.
119 /// </summary>
120 /// <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>
121 /// <param name="index">The zero-based index in array at which copying begins.</param>
122 /// <exception cref="T:System.ArgumentNullException">array is null. </exception>
123 /// <exception cref="T:System.ArgumentOutOfRangeException">index is less than zero. </exception>
124 /// <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>
125 /// <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>
126 public void CopyTo(Array array, int index)
128 map.CopyTo(array, index);
131 /// <summary>
132 /// Gets an object that can be used to synchronize access to the <see cref="T:System.Collections.ICollection"></see>.
133 /// </summary>
134 /// <value></value>
135 /// <returns>An object that can be used to synchronize access to the <see cref="T:System.Collections.ICollection"></see>.</returns>
136 public object SyncRoot
138 get { return map.SyncRoot; }
141 #endregion
143 #region IEnumerable Members
145 /// <summary>
146 /// Returns an enumerator that iterates through a collection.
147 /// </summary>
148 /// <returns>
149 /// An <see cref="T:System.Collections.IEnumerator"></see> object that can be used to iterate through the collection.
150 /// </returns>
151 IEnumerator System.Collections.IEnumerable.GetEnumerator()
153 return map.GetEnumerator();
156 #endregion