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.
18 using System
.Collections
;
19 using Castle
.Core
.Internal
;
22 /// Collection of <see cref="InterceptorReference"/>
25 public class InterceptorReferenceCollection
: ICollection
27 private readonly LinkedList list
= new LinkedList();
30 /// Adds the specified interceptor.
32 /// <param name="interceptor">The interceptor.</param>
33 public void Add(InterceptorReference interceptor
)
35 list
.Add(interceptor
);
39 /// Adds the the specified interceptor as the first.
41 /// <param name="interceptor">The interceptor.</param>
42 public void AddFirst(InterceptorReference interceptor
)
44 list
.AddFirst(interceptor
);
48 /// Adds the the specified interceptor as the last.
50 /// <param name="interceptor">The interceptor.</param>
51 public void AddLast(InterceptorReference interceptor
)
53 list
.AddLast(interceptor
);
57 /// Inserts the specified interceptor at the specified index.
59 /// <param name="index">The index.</param>
60 /// <param name="interceptor">The interceptor.</param>
61 public void Insert(int index
, InterceptorReference interceptor
)
63 list
.Insert(index
, interceptor
);
67 /// Gets a value indicating whether this instance has interceptors.
70 /// <c>true</c> if this instance has interceptors; otherwise, <c>false</c>.
72 public bool HasInterceptors
74 get { return Count != 0; }
78 /// When implemented by a class, copies the elements of
79 /// the <see cref="T:System.Collections.ICollection"/> to an <see cref="T:System.Array"/>, starting at a particular <see cref="T:System.Array"/> index.
81 /// <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>
82 /// <param name="index">The zero-based index in <paramref name="array"/> at which copying begins.</param>
83 /// <exception cref="T:System.ArgumentNullException">
84 /// <paramref name="array"/> is <see langword="null"/>.</exception>
85 /// <exception cref="T:System.ArgumentOutOfRangeException">
86 /// <paramref name="index"/> is less than zero.</exception>
87 /// <exception cref="T:System.ArgumentException">
89 /// <paramref name="array"/> is multidimensional.</para>
92 /// <paramref name="index"/> is equal to or greater than the length of <paramref name="array"/>.</para>
94 /// <para>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"/>.</para>
96 /// <exception cref="T:System.InvalidCastException">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>
97 public void CopyTo(Array array
, int index
)
99 throw new NotImplementedException();
103 /// Gets the number of
104 /// elements contained in the <see cref="T:System.Collections.ICollection"/>.
109 get { return list.Count; }
113 /// Gets an object that
114 /// can be used to synchronize access to the <see cref="T:System.Collections.ICollection"/>.
117 public object SyncRoot
124 /// indicating whether access to the <see cref="T:System.Collections.ICollection"/> is synchronized
128 public bool IsSynchronized
130 get { return false; }
134 /// Returns an enumerator that can iterate through a collection.
137 /// An <see cref="T:System.Collections.IEnumerator"/>
138 /// that can be used to iterate through the collection.
140 public IEnumerator
GetEnumerator()
142 return list
.GetEnumerator();
146 /// Adds the interceptor to the end of the interceptors list if it does not exist already.
148 /// <param name="interceptorReference">The interceptor reference.</param>
149 public void AddIfNotInCollection(InterceptorReference interceptorReference
)
151 if (list
.Contains(interceptorReference
) == false)
152 list
.AddLast(interceptorReference
);