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
.ActiveRecord
.Framework
.Internal
18 using System
.Collections
;
21 /// Map System.Type to their ActiveRecordModel
23 public class ActiveRecordModelCollection
: DictionaryBase
, IEnumerable
26 /// Adds the specified model.
28 /// <param name="model">The model.</param>
29 public void Add(ActiveRecordModel model
)
31 Dictionary
.Add(model
.Type
, model
);
35 /// Determines whether the collection contains the specified type.
37 /// <param name="type">The type.</param>
39 /// <c>true</c> if the collection contains the specified type; otherwise, <c>false</c>.
41 public bool Contains(Type type
)
43 return Dictionary
.Contains(type
);
47 /// Gets the <see cref="Castle.ActiveRecord.Framework.Internal.ActiveRecordModel"/> with the specified type.
50 public ActiveRecordModel
this[Type type
]
52 get { return Dictionary[type] as ActiveRecordModel; }
55 #region IEnumerable Members
58 /// Returns an enumerator that iterates through a collection.
61 /// An <see cref="T:System.Collections.IEnumerator"></see> object that can be used to iterate through the collection.
63 public new IEnumerator
GetEnumerator()
65 return Dictionary
.Values
.GetEnumerator();