Fixing an issue with output parameters that are of type IntPtr
[castle.git] / Components / Binder / Castle.Components.Binder / ErrorList.cs
blob728734d315670587fb866995c65f7a1c6d7660dd
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.Components.Binder
17 using System;
18 using System.Collections;
20 /// <summary>
21 /// A useful representation of a set of IPropertyError instances.
22 /// </summary>
23 [Serializable]
24 public class ErrorList : ICollection
26 private readonly SortedList entries = new SortedList();
28 /// <summary>
29 /// Initializes a new instance of the <see cref="ErrorList"/> class.
30 /// </summary>
31 /// <param name="initialContents">The initial contents.</param>
32 public ErrorList(IList initialContents)
34 IList list = (initialContents != null ? initialContents : new ArrayList(0));
36 foreach(DataBindError error in list)
38 entries[error.Property] = error;
42 /// <summary>
43 /// Gets the number of elements contained in the <see cref="T:System.Collections.ICollection"></see>.
44 /// </summary>
45 /// <value></value>
46 /// <returns>The number of elements contained in the <see cref="T:System.Collections.ICollection"></see>.</returns>
47 public int Count
49 get { return entries.Count; }
52 /// <summary>
53 /// Determines whether [contains] [the specified property].
54 /// </summary>
55 /// <param name="property">The property.</param>
56 /// <returns>
57 /// <c>true</c> if [contains] [the specified property]; otherwise, <c>false</c>.
58 /// </returns>
59 public bool Contains(String property)
61 return entries.Contains(property);
64 /// <summary>
65 /// Gets the <see cref="Castle.Components.Binder.DataBindError"/> with the specified property.
66 /// </summary>
67 /// <value></value>
68 public DataBindError this[String property]
70 get { return entries[property] as DataBindError; }
73 #region ICollection Members
75 public void CopyTo(Array array, int index)
77 throw new NotImplementedException();
80 public object SyncRoot
82 get { return this; }
85 public bool IsSynchronized
87 get { return false; }
90 #endregion
92 #region IEnumerable Members
94 public IEnumerator GetEnumerator()
96 return entries.Values.GetEnumerator();
99 #endregion