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"/>
27 public class InterceptorReferenceCollection
: ICollection
29 private readonly LinkedList list
= new LinkedList();
32 /// Adds the specified interceptor.
34 /// <param name="interceptor">The interceptor.</param>
35 public void Add(InterceptorReference interceptor
)
37 list
.Add(interceptor
);
41 /// Adds the the specified interceptor as the first.
43 /// <param name="interceptor">The interceptor.</param>
44 public void AddFirst(InterceptorReference interceptor
)
46 list
.AddFirst(interceptor
);
50 /// Adds the the specified interceptor as the last.
52 /// <param name="interceptor">The interceptor.</param>
53 public void AddLast(InterceptorReference interceptor
)
55 list
.AddLast(interceptor
);
59 /// Inserts the specified interceptor at the specified index.
61 /// <param name="index">The index.</param>
62 /// <param name="interceptor">The interceptor.</param>
63 public void Insert(int index
, InterceptorReference interceptor
)
65 list
.Insert(index
, interceptor
);
69 /// Gets a value indicating whether this instance has interceptors.
72 /// <c>true</c> if this instance has interceptors; otherwise, <c>false</c>.
74 public bool HasInterceptors
76 get { return Count != 0; }
80 /// When implemented by a class, copies the elements of
81 /// the <see cref="T:System.Collections.ICollection"/> to an <see cref="T:System.Array"/>, starting at a particular <see cref="T:System.Array"/> index.
83 /// <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>
84 /// <param name="index">The zero-based index in <paramref name="array"/> at which copying begins.</param>
85 /// <exception cref="T:System.ArgumentNullException">
86 /// <paramref name="array"/> is <see langword="null"/>.</exception>
87 /// <exception cref="T:System.ArgumentOutOfRangeException">
88 /// <paramref name="index"/> is less than zero.</exception>
89 /// <exception cref="T:System.ArgumentException">
91 /// <paramref name="array"/> is multidimensional.</para>
94 /// <paramref name="index"/> is equal to or greater than the length of <paramref name="array"/>.</para>
96 /// <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>
98 /// <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>
99 public void CopyTo(Array array
, int index
)
101 throw new NotImplementedException();
105 /// Gets the number of
106 /// elements contained in the <see cref="T:System.Collections.ICollection"/>.
111 get { return list.Count; }
115 /// Gets an object that
116 /// can be used to synchronize access to the <see cref="T:System.Collections.ICollection"/>.
119 public object SyncRoot
126 /// indicating whether access to the <see cref="T:System.Collections.ICollection"/> is synchronized
130 public bool IsSynchronized
132 get { return false; }
136 /// Returns an enumerator that can iterate through a collection.
139 /// An <see cref="T:System.Collections.IEnumerator"/>
140 /// that can be used to iterate through the collection.
142 public IEnumerator
GetEnumerator()
144 return list
.GetEnumerator();
148 /// Adds the interceptor to the end of the interceptors list if it does not exist already.
150 /// <param name="interceptorReference">The interceptor reference.</param>
151 public void AddIfNotInCollection(InterceptorReference interceptorReference
)
153 if (list
.Contains(interceptorReference
) == false)
154 list
.AddLast(interceptorReference
);