Added RedirectUsingNamedRoute
[castle.git] / Core / Castle.Core / Model / ConstructorCandidateCollection.cs
blobd42c952f3728e335dedef64a8fda4957675b8ca5
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;
20 /// <summary>
21 /// Collection of <see cref="ConstructorCandidate"/>
22 /// </summary>
23 [Serializable]
24 public class ConstructorCandidateCollection : ReadOnlyCollectionBase
26 private bool hasAmbiguousFewerArgumentsCandidate;
27 private ConstructorCandidate fewerArgumentsCandidate;
29 /// <summary>
30 /// Adds the specified candidate.
31 /// </summary>
32 /// <param name="candidate">The candidate.</param>
33 public void Add(ConstructorCandidate candidate)
35 if (fewerArgumentsCandidate == null)
37 fewerArgumentsCandidate = candidate;
38 hasAmbiguousFewerArgumentsCandidate = false;
40 else
42 int constructorParamCount = candidate.Constructor.GetParameters().Length;
43 int fewerArgumentsCount = fewerArgumentsCandidate.Constructor.GetParameters().Length;
45 if (constructorParamCount < fewerArgumentsCount)
47 fewerArgumentsCandidate = candidate;
49 else if (constructorParamCount == fewerArgumentsCount)
51 hasAmbiguousFewerArgumentsCandidate = true;
55 InnerList.Add(candidate);
58 /// <summary>
59 /// Gets the fewer arguments candidate.
60 /// </summary>
61 /// <value>The fewer arguments candidate.</value>
62 public ConstructorCandidate FewerArgumentsCandidate
64 get { return fewerArgumentsCandidate; }
67 public bool HasAmbiguousFewerArgumentsCandidate
69 get { return hasAmbiguousFewerArgumentsCandidate; }
72 /// <summary>
73 /// Clears this instance.
74 /// </summary>
75 public void Clear()
77 InnerList.Clear();