Fixing an issue with output parameters that are of type IntPtr
[castle.git] / Core / Castle.Core / Model / ConstructorCandidateCollection.cs
blobb10eafb5e32e7b50a9c02edba577608ebf3abe47
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 #if !SILVERLIGHT
24 [Serializable]
25 #endif
26 public class ConstructorCandidateCollection : ReadOnlyCollectionBase
28 private bool hasAmbiguousFewerArgumentsCandidate;
29 private ConstructorCandidate fewerArgumentsCandidate;
31 /// <summary>
32 /// Adds the specified candidate.
33 /// </summary>
34 /// <param name="candidate">The candidate.</param>
35 public void Add(ConstructorCandidate candidate)
37 if (fewerArgumentsCandidate == null)
39 fewerArgumentsCandidate = candidate;
40 hasAmbiguousFewerArgumentsCandidate = false;
42 else
44 int constructorParamCount = candidate.Constructor.GetParameters().Length;
45 int fewerArgumentsCount = fewerArgumentsCandidate.Constructor.GetParameters().Length;
47 if (constructorParamCount < fewerArgumentsCount)
49 fewerArgumentsCandidate = candidate;
51 else if (constructorParamCount == fewerArgumentsCount)
53 hasAmbiguousFewerArgumentsCandidate = true;
57 InnerList.Add(candidate);
60 /// <summary>
61 /// Gets the fewer arguments candidate.
62 /// </summary>
63 /// <value>The fewer arguments candidate.</value>
64 public ConstructorCandidate FewerArgumentsCandidate
66 get { return fewerArgumentsCandidate; }
69 public bool HasAmbiguousFewerArgumentsCandidate
71 get { return hasAmbiguousFewerArgumentsCandidate; }
74 /// <summary>
75 /// Clears this instance.
76 /// </summary>
77 public void Clear()
79 InnerList.Clear();