Fixing an issue with output parameters that are of type IntPtr
[castle.git] / Core / Castle.Core / Model / Configuration / ConfigurationCollection.cs
bloba0ebe01e7f8dccd84e0c425e7d04ee6e6a747502
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.Core.Configuration
17 using System;
18 using System.Collections;
20 /// <summary>
21 /// A collection of <see cref="IConfiguration"/> objects.
22 /// </summary>
23 #if !SILVERLIGHT
24 [Serializable]
25 #endif
26 public class ConfigurationCollection : ReadOnlyCollectionBase
28 /// <summary>
29 /// Creates a new instance of <c>ConfigurationCollection</c>.
30 /// </summary>
31 public ConfigurationCollection()
35 /// <summary>
36 /// Creates a new instance of <c>ConfigurationCollection</c>.
37 /// </summary>
38 public ConfigurationCollection(ConfigurationCollection value)
40 AddRange(value);
43 /// <summary>
44 /// Creates a new instance of <c>ConfigurationCollection</c>.
45 /// </summary>
46 public ConfigurationCollection(IConfiguration[] value)
48 AddRange(value);
51 /// <summary>
52 /// Represents the entry at the specified index of the <see cref="IConfiguration"/>.
53 /// </summary>
54 /// <param name="index">
55 /// The zero-based index of the entry to locate in the collection.
56 /// </param>
57 /// <value>
58 /// The entry at the specified index of the collection.
59 /// </value>
60 /// <exception cref="System.ArgumentOutOfRangeException">
61 /// <paramref name="index"/> is outside the valid range of indexes for the collection.
62 /// </exception>
63 public IConfiguration this[int index]
65 get { return (IConfiguration) InnerList[index]; }
66 set { InnerList[index] = value; }
69 public IConfiguration this[String name]
71 get
73 foreach(IConfiguration config in InnerList)
75 if (name.Equals(config.Name))
77 return config;
81 return null;
85 /// <summary>
86 /// Adds an <see cref="IConfiguration"/>.
87 /// </summary>
88 /// <param name="value">The <see cref="IConfiguration"/> to add.</param>
89 /// <returns>
90 /// The index at which the new element was inserted.
91 /// </returns>
92 public IConfiguration Add(IConfiguration value)
94 InnerList.Add(value);
95 return value;
98 /// <summary>
99 /// Adds an array of <see cref="IConfiguration"/>.
100 /// </summary>
101 /// <param name="value">The Array of <see cref="IConfiguration"/> to add.</param>
102 public void AddRange(IConfiguration[] value)
104 foreach(IConfiguration configuration in value)
106 Add(configuration);
110 /// <summary>
111 /// Adds a <see cref="ConfigurationCollection"/>.
112 /// </summary>
113 /// <param name="value">The <see cref="ConfigurationCollection"/> to add.</param>
114 public void AddRange(ConfigurationCollection value)
116 foreach(IConfiguration configuration in value)
118 Add(configuration);
122 /// <summary>
123 /// Copies the elements to a one-dimensional <see cref="Array"/> instance at the specified index.
124 /// </summary>
125 /// <param name="array">
126 /// The one-dimensional <see cref="Array"/> must have zero-based indexing.
127 /// </param>
128 /// <param name="index">The zero-based index in array at which copying begins.</param>
129 public void CopyTo(IConfiguration[] array, int index)
131 InnerList.CopyTo(array, index);
134 /// <summary>
135 /// Gets a value indicating whether the <see cref="IConfiguration"/> contains
136 /// in the collection.
137 /// </summary>
138 /// <param name="value">The <see cref="IConfiguration"/> to locate.</param>
139 /// <returns>
140 /// <see langword="true"/> if the <see cref="IConfiguration"/> is contained in the collection;
141 /// otherwise, <see langword="false"/>.
142 /// </returns>
143 public bool Contains(IConfiguration value)
145 return InnerList.Contains(value);
148 /// <summary>
149 /// Removes a specific <see cref="IConfiguration"/> from the
150 /// collection.
151 /// </summary>
152 /// <param name="value">The <see cref="IConfiguration"/> to remove from the collection.</param>
153 /// <exception cref="ArgumentException">
154 /// <paramref name="value"/> is not found in the collection.
155 /// </exception>
156 public void Remove(IConfiguration value)
158 InnerList.Remove(value);