Fixing an issue with output parameters that are of type IntPtr
[castle.git] / Core / Castle.Core / Model / InterceptorReferenceCollection.cs
blobb2532579a89f080500f24b474b571929dbe7d18b
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
17 using System;
18 using System.Collections;
19 using Castle.Core.Internal;
21 /// <summary>
22 /// Collection of <see cref="InterceptorReference"/>
23 /// </summary>
24 #if !SILVERLIGHT
25 [Serializable]
26 #endif
27 public class InterceptorReferenceCollection : ICollection
29 private readonly LinkedList list = new LinkedList();
31 /// <summary>
32 /// Adds the specified interceptor.
33 /// </summary>
34 /// <param name="interceptor">The interceptor.</param>
35 public void Add(InterceptorReference interceptor)
37 list.Add(interceptor);
40 /// <summary>
41 /// Adds the the specified interceptor as the first.
42 /// </summary>
43 /// <param name="interceptor">The interceptor.</param>
44 public void AddFirst(InterceptorReference interceptor)
46 list.AddFirst(interceptor);
49 /// <summary>
50 /// Adds the the specified interceptor as the last.
51 /// </summary>
52 /// <param name="interceptor">The interceptor.</param>
53 public void AddLast(InterceptorReference interceptor)
55 list.AddLast(interceptor);
58 /// <summary>
59 /// Inserts the specified interceptor at the specified index.
60 /// </summary>
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);
68 /// <summary>
69 /// Gets a value indicating whether this instance has interceptors.
70 /// </summary>
71 /// <value>
72 /// <c>true</c> if this instance has interceptors; otherwise, <c>false</c>.
73 /// </value>
74 public bool HasInterceptors
76 get { return Count != 0; }
79 /// <summary>
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.
82 /// </summary>
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">
90 /// <para>
91 /// <paramref name="array"/> is multidimensional.</para>
92 /// <para>-or-</para>
93 /// <para>
94 /// <paramref name="index"/> is equal to or greater than the length of <paramref name="array"/>.</para>
95 /// <para>-or-</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>
97 /// </exception>
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();
104 /// <summary>
105 /// Gets the number of
106 /// elements contained in the <see cref="T:System.Collections.ICollection"/>.
107 /// </summary>
108 /// <value></value>
109 public int Count
111 get { return list.Count; }
114 /// <summary>
115 /// Gets an object that
116 /// can be used to synchronize access to the <see cref="T:System.Collections.ICollection"/>.
117 /// </summary>
118 /// <value></value>
119 public object SyncRoot
121 get { return list; }
124 /// <summary>
125 /// Gets a value
126 /// indicating whether access to the <see cref="T:System.Collections.ICollection"/> is synchronized
127 /// (thread-safe).
128 /// </summary>
129 /// <value></value>
130 public bool IsSynchronized
132 get { return false; }
135 /// <summary>
136 /// Returns an enumerator that can iterate through a collection.
137 /// </summary>
138 /// <returns>
139 /// An <see cref="T:System.Collections.IEnumerator"/>
140 /// that can be used to iterate through the collection.
141 /// </returns>
142 public IEnumerator GetEnumerator()
144 return list.GetEnumerator();
147 /// <summary>
148 /// Adds the interceptor to the end of the interceptors list if it does not exist already.
149 /// </summary>
150 /// <param name="interceptorReference">The interceptor reference.</param>
151 public void AddIfNotInCollection(InterceptorReference interceptorReference)
153 if (list.Contains(interceptorReference) == false)
154 list.AddLast(interceptorReference);