Fix the build.
[castle.git] / MonoRail / Castle.MonoRail.Framework / Internal / ReflectionBasedDictionaryAdapter.cs
blob0218bf6a9b09d684eba1011a96a91cd6d20237ec
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.Reflection;
21 /// <summary>
22 /// Pendent
23 /// </summary>
24 public class ReflectionBasedDictionaryAdapter : IDictionary
26 private readonly object target;
27 private readonly Type targetType;
28 private readonly BindingFlags flags = BindingFlags.Instance | BindingFlags.IgnoreCase | BindingFlags.Public;
30 /// <summary>
31 /// Initializes a new instance of the <see cref="ReflectionBasedDictionaryAdapter"/> class.
32 /// </summary>
33 /// <param name="target">The target.</param>
34 public ReflectionBasedDictionaryAdapter(object target)
36 if (target == null)
38 throw new ArgumentNullException("target");
41 this.target = target;
42 targetType = target.GetType();
45 /// <summary>
46 /// Determines whether the <see cref="T:System.Collections.IDictionary"/> object contains an element with the specified key.
47 /// </summary>
48 /// <param name="key">The key to locate in the <see cref="T:System.Collections.IDictionary"/> object.</param>
49 /// <returns>
50 /// true if the <see cref="T:System.Collections.IDictionary"/> contains an element with the key; otherwise, false.
51 /// </returns>
52 /// <exception cref="T:System.ArgumentNullException">
53 /// <paramref name="key"/> is null. </exception>
54 public bool Contains(object key)
56 return targetType.GetProperty(key.ToString(), flags) != null;
59 /// <summary>
60 /// Gets or sets the <see cref="System.Object"/> with the specified key.
61 /// </summary>
62 /// <value></value>
63 public object this[object key]
65 get
67 PropertyInfo prop = targetType.GetProperty(key.ToString(), flags);
69 if (prop == null)
71 return null;
74 return prop.GetValue(target, null);
76 set { throw new NotImplementedException(); }
79 /// <summary>
80 /// Adds an element with the provided key and value to the <see cref="T:System.Collections.IDictionary"/> object.
81 /// </summary>
82 /// <param name="key">The <see cref="T:System.Object"/> to use as the key of the element to add.</param>
83 /// <param name="value">The <see cref="T:System.Object"/> to use as the value of the element to add.</param>
84 /// <exception cref="T:System.ArgumentNullException">
85 /// <paramref name="key"/> is null. </exception>
86 /// <exception cref="T:System.ArgumentException">An element with the same key already exists in the <see cref="T:System.Collections.IDictionary"/> object. </exception>
87 /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.IDictionary"/> is read-only.-or- The <see cref="T:System.Collections.IDictionary"/> has a fixed size. </exception>
88 public void Add(object key, object value)
90 throw new NotImplementedException();
93 /// <summary>
94 /// Removes all elements from the <see cref="T:System.Collections.IDictionary"/> object.
95 /// </summary>
96 /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.IDictionary"/> object is read-only. </exception>
97 public void Clear()
99 throw new NotImplementedException();
102 /// <summary>
103 /// Returns an <see cref="T:System.Collections.IDictionaryEnumerator"/> object for the <see cref="T:System.Collections.IDictionary"/> object.
104 /// </summary>
105 /// <returns>
106 /// An <see cref="T:System.Collections.IDictionaryEnumerator"/> object for the <see cref="T:System.Collections.IDictionary"/> object.
107 /// </returns>
108 IDictionaryEnumerator IDictionary.GetEnumerator()
110 throw new NotImplementedException();
113 /// <summary>
114 /// Removes the element with the specified key from the <see cref="T:System.Collections.IDictionary"/> object.
115 /// </summary>
116 /// <param name="key">The key of the element to remove.</param>
117 /// <exception cref="T:System.ArgumentNullException">
118 /// <paramref name="key"/> is null. </exception>
119 /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.IDictionary"/> object is read-only.-or- The <see cref="T:System.Collections.IDictionary"/> has a fixed size. </exception>
120 public void Remove(object key)
122 throw new NotImplementedException();
125 /// <summary>
126 /// Gets an <see cref="T:System.Collections.ICollection"/> object containing the keys of the <see cref="T:System.Collections.IDictionary"/> object.
127 /// </summary>
128 /// <value></value>
129 /// <returns>An <see cref="T:System.Collections.ICollection"/> object containing the keys of the <see cref="T:System.Collections.IDictionary"/> object.</returns>
130 public ICollection Keys
132 get { throw new NotImplementedException(); }
135 /// <summary>
136 /// Gets an <see cref="T:System.Collections.ICollection"/> object containing the values in the <see cref="T:System.Collections.IDictionary"/> object.
137 /// </summary>
138 /// <value></value>
139 /// <returns>An <see cref="T:System.Collections.ICollection"/> object containing the values in the <see cref="T:System.Collections.IDictionary"/> object.</returns>
140 public ICollection Values
142 get { throw new NotImplementedException(); }
145 /// <summary>
146 /// Gets a value indicating whether the <see cref="T:System.Collections.IDictionary"/> object is read-only.
147 /// </summary>
148 /// <value></value>
149 /// <returns>true if the <see cref="T:System.Collections.IDictionary"/> object is read-only; otherwise, false.</returns>
150 public bool IsReadOnly
152 get { throw new NotImplementedException(); }
155 /// <summary>
156 /// Gets a value indicating whether the <see cref="T:System.Collections.IDictionary"/> object has a fixed size.
157 /// </summary>
158 /// <value></value>
159 /// <returns>true if the <see cref="T:System.Collections.IDictionary"/> object has a fixed size; otherwise, false.</returns>
160 public bool IsFixedSize
162 get { throw new NotImplementedException(); }
165 /// <summary>
166 /// Copies the elements of the <see cref="T:System.Collections.ICollection"/> to an <see cref="T:System.Array"/>, starting at a particular <see cref="T:System.Array"/> index.
167 /// </summary>
168 /// <param name="array">The one-dimensional <see cref="T:System.Array"/> that is the destination of the elements copied from <see cref="T:System.Collections.ICollection"/>. The <see cref="T:System.Array"/> must have zero-based indexing.</param>
169 /// <param name="index">The zero-based index in <paramref name="array"/> at which copying begins.</param>
170 /// <exception cref="T:System.ArgumentNullException">
171 /// <paramref name="array"/> is null. </exception>
172 /// <exception cref="T:System.ArgumentOutOfRangeException">
173 /// <paramref name="index"/> is less than zero. </exception>
174 /// <exception cref="T:System.ArgumentException">
175 /// <paramref name="array"/> is multidimensional.-or- <paramref name="index"/> is equal to or greater than the length of <paramref name="array"/>.-or- The number of elements in the source <see cref="T:System.Collections.ICollection"/> is greater than the available space from <paramref name="index"/> to the end of the destination <paramref name="array"/>. </exception>
176 /// <exception cref="T:System.ArgumentException">The type of the source <see cref="T:System.Collections.ICollection"/> cannot be cast automatically to the type of the destination <paramref name="array"/>. </exception>
177 public void CopyTo(Array array, int index)
179 throw new NotImplementedException();
182 /// <summary>
183 /// Gets the number of elements contained in the <see cref="T:System.Collections.ICollection"/>.
184 /// </summary>
185 /// <value></value>
186 /// <returns>The number of elements contained in the <see cref="T:System.Collections.ICollection"/>.</returns>
187 public int Count
189 get { throw new NotImplementedException(); }
192 /// <summary>
193 /// Gets an object that can be used to synchronize access to the <see cref="T:System.Collections.ICollection"/>.
194 /// </summary>
195 /// <value></value>
196 /// <returns>An object that can be used to synchronize access to the <see cref="T:System.Collections.ICollection"/>.</returns>
197 public object SyncRoot
199 get { throw new NotImplementedException(); }
202 /// <summary>
203 /// Gets a value indicating whether access to the <see cref="T:System.Collections.ICollection"/> is synchronized (thread safe).
204 /// </summary>
205 /// <value></value>
206 /// <returns>true if access to the <see cref="T:System.Collections.ICollection"/> is synchronized (thread safe); otherwise, false.</returns>
207 public bool IsSynchronized
209 get { throw new NotImplementedException(); }
212 /// <summary>
213 /// Returns an enumerator that iterates through a collection.
214 /// </summary>
215 /// <returns>
216 /// An <see cref="T:System.Collections.IEnumerator"/> object that can be used to iterate through the collection.
217 /// </returns>
218 public IEnumerator GetEnumerator()
220 throw new NotImplementedException();