Removed untyped contructor from ComponentRegistration and add a protected setter.
[castle.git] / Core / Castle.Core / Model / Configuration / ConfigurationCollection.cs
blob1b1767b918cfb81d842fe6f70b4bb107d52099e0
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 [Serializable]
24 public class ConfigurationCollection : ReadOnlyCollectionBase
26 /// <summary>
27 /// Creates a new instance of <c>ConfigurationCollection</c>.
28 /// </summary>
29 public ConfigurationCollection()
33 /// <summary>
34 /// Creates a new instance of <c>ConfigurationCollection</c>.
35 /// </summary>
36 public ConfigurationCollection(ConfigurationCollection value)
38 AddRange(value);
41 /// <summary>
42 /// Creates a new instance of <c>ConfigurationCollection</c>.
43 /// </summary>
44 public ConfigurationCollection(IConfiguration[] value)
46 AddRange(value);
49 /// <summary>
50 /// Represents the entry at the specified index of the <see cref="IConfiguration"/>.
51 /// </summary>
52 /// <param name="index">
53 /// The zero-based index of the entry to locate in the collection.
54 /// </param>
55 /// <value>
56 /// The entry at the specified index of the collection.
57 /// </value>
58 /// <exception cref="System.ArgumentOutOfRangeException">
59 /// <paramref name="index"/> is outside the valid range of indexes for the collection.
60 /// </exception>
61 public IConfiguration this[int index]
63 get { return (IConfiguration) InnerList[index]; }
64 set { InnerList[index] = value; }
67 public IConfiguration this[String name]
69 get
71 foreach(IConfiguration config in InnerList)
73 if (name.Equals(config.Name))
75 return config;
79 return null;
83 /// <summary>
84 /// Adds an <see cref="IConfiguration"/>.
85 /// </summary>
86 /// <param name="value">The <see cref="IConfiguration"/> to add.</param>
87 /// <returns>
88 /// The index at which the new element was inserted.
89 /// </returns>
90 public IConfiguration Add(IConfiguration value)
92 InnerList.Add(value);
93 return value;
96 /// <summary>
97 /// Adds an array of <see cref="IConfiguration"/>.
98 /// </summary>
99 /// <param name="value">The Array of <see cref="IConfiguration"/> to add.</param>
100 public void AddRange(IConfiguration[] value)
102 foreach(IConfiguration configuration in value)
104 Add(configuration);
108 /// <summary>
109 /// Adds a <see cref="ConfigurationCollection"/>.
110 /// </summary>
111 /// <param name="value">The <see cref="ConfigurationCollection"/> to add.</param>
112 public void AddRange(ConfigurationCollection value)
114 foreach(IConfiguration configuration in value)
116 Add(configuration);
120 /// <summary>
121 /// Copies the elements to a one-dimensional <see cref="Array"/> instance at the specified index.
122 /// </summary>
123 /// <param name="array">
124 /// The one-dimensional <see cref="Array"/> must have zero-based indexing.
125 /// </param>
126 /// <param name="index">The zero-based index in array at which copying begins.</param>
127 public void CopyTo(IConfiguration[] array, int index)
129 InnerList.CopyTo(array, index);
132 /// <summary>
133 /// Gets a value indicating whether the <see cref="IConfiguration"/> contains
134 /// in the collection.
135 /// </summary>
136 /// <param name="value">The <see cref="IConfiguration"/> to locate.</param>
137 /// <returns>
138 /// <see langword="true"/> if the <see cref="IConfiguration"/> is contained in the collection;
139 /// otherwise, <see langword="false"/>.
140 /// </returns>
141 public bool Contains(IConfiguration value)
143 return InnerList.Contains(value);
146 /// <summary>
147 /// Removes a specific <see cref="IConfiguration"/> from the
148 /// collection.
149 /// </summary>
150 /// <param name="value">The <see cref="IConfiguration"/> to remove from the collection.</param>
151 /// <exception cref="ArgumentException">
152 /// <paramref name="value"/> is not found in the collection.
153 /// </exception>
154 public void Remove(IConfiguration value)
156 InnerList.Remove(value);