1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
18 using System
.Collections
;
21 /// A collection of <see cref="IConfiguration"/> objects.
26 public class ConfigurationCollection
: ReadOnlyCollectionBase
29 /// Creates a new instance of <c>ConfigurationCollection</c>.
31 public ConfigurationCollection()
36 /// Creates a new instance of <c>ConfigurationCollection</c>.
38 public ConfigurationCollection(ConfigurationCollection
value)
44 /// Creates a new instance of <c>ConfigurationCollection</c>.
46 public ConfigurationCollection(IConfiguration
[] value)
52 /// Represents the entry at the specified index of the <see cref="IConfiguration"/>.
54 /// <param name="index">
55 /// The zero-based index of the entry to locate in the collection.
58 /// The entry at the specified index of the collection.
60 /// <exception cref="System.ArgumentOutOfRangeException">
61 /// <paramref name="index"/> is outside the valid range of indexes for the collection.
63 public IConfiguration
this[int index
]
65 get { return (IConfiguration) InnerList[index]; }
66 set { InnerList[index] = value; }
69 public IConfiguration
this[String name
]
73 foreach(IConfiguration config
in InnerList
)
75 if (name
.Equals(config
.Name
))
86 /// Adds an <see cref="IConfiguration"/>.
88 /// <param name="value">The <see cref="IConfiguration"/> to add.</param>
90 /// The index at which the new element was inserted.
92 public IConfiguration
Add(IConfiguration
value)
99 /// Adds an array of <see cref="IConfiguration"/>.
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)
111 /// Adds a <see cref="ConfigurationCollection"/>.
113 /// <param name="value">The <see cref="ConfigurationCollection"/> to add.</param>
114 public void AddRange(ConfigurationCollection
value)
116 foreach(IConfiguration configuration
in value)
123 /// Copies the elements to a one-dimensional <see cref="Array"/> instance at the specified index.
125 /// <param name="array">
126 /// The one-dimensional <see cref="Array"/> must have zero-based indexing.
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
);
135 /// Gets a value indicating whether the <see cref="IConfiguration"/> contains
136 /// in the collection.
138 /// <param name="value">The <see cref="IConfiguration"/> to locate.</param>
140 /// <see langword="true"/> if the <see cref="IConfiguration"/> is contained in the collection;
141 /// otherwise, <see langword="false"/>.
143 public bool Contains(IConfiguration
value)
145 return InnerList
.Contains(value);
149 /// Removes a specific <see cref="IConfiguration"/> from the
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.
156 public void Remove(IConfiguration
value)
158 InnerList
.Remove(value);