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
.Components
.Binder
18 using System
.Collections
;
21 /// A useful representation of a set of IPropertyError instances.
24 public class ErrorList
: ICollection
26 private readonly SortedList entries
= new SortedList();
29 /// Initializes a new instance of the <see cref="ErrorList"/> class.
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
;
43 /// Gets the number of elements contained in the <see cref="T:System.Collections.ICollection"></see>.
46 /// <returns>The number of elements contained in the <see cref="T:System.Collections.ICollection"></see>.</returns>
49 get { return entries.Count; }
53 /// Determines whether [contains] [the specified property].
55 /// <param name="property">The property.</param>
57 /// <c>true</c> if [contains] [the specified property]; otherwise, <c>false</c>.
59 public bool Contains(String property
)
61 return entries
.Contains(property
);
65 /// Gets the <see cref="Castle.Components.Binder.DataBindError"/> with the specified property.
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
85 public bool IsSynchronized
92 #region IEnumerable Members
94 public IEnumerator
GetEnumerator()
96 return entries
.Values
.GetEnumerator();