Forgot this in changelog
[mono.git] / mcs / class / Microsoft.Build.Engine / Microsoft.Build.BuildEngine / TargetCollection.cs
index f0919aca24d310b45daa4a39678ee1a6ffd00078..8089806ef43a6df9cb6bd56f03658e40a68db2dd 100644 (file)
 
 using System;
 using System.Collections;
+using System.Collections.Generic;
 using System.Reflection;
 
 namespace Microsoft.Build.BuildEngine {
        public class TargetCollection : ICollection, IEnumerable {
                
-               IDictionary     targetsByName;
-               Project         parentProject;
+               Dictionary <string, Target>     targetsByName;
+               //Project                               parentProject;
        
                internal TargetCollection (Project project)
                {
-                       this.targetsByName = new Hashtable ();
-                       this.parentProject = project;
+                       this.targetsByName = new Dictionary <string, Target> (StringComparer.InvariantCultureIgnoreCase);
+                       //this.parentProject = project;
                }
 
                // This must create a new xml element and stuff.
@@ -57,19 +58,18 @@ namespace Microsoft.Build.BuildEngine {
 
                public void CopyTo (Array array, int index)
                {
-                       targetsByName.Values.CopyTo (array, index);
+                       targetsByName.Values.CopyTo ((Target[]) array, index);
                }
 
                public bool Exists (string targetName)
                {
-                       return targetsByName.Contains (targetName);
+                       return targetsByName.ContainsKey (targetName);
                }
 
                public IEnumerator GetEnumerator ()
                {
-                       foreach (DictionaryEntry de in targetsByName) {
-                               yield return (Target)de.Key;
-                       }
+                       foreach (KeyValuePair <string, Target> kvp in targetsByName)
+                               yield return kvp.Value;
                }
 
                public void RemoveTarget (Target targetToRemove)
@@ -95,9 +95,12 @@ namespace Microsoft.Build.BuildEngine {
                        }
                }
 
-               public Target this[string index] {
+               public Target this [string index] {
                        get {
-                               return (Target) targetsByName [index];
+                               if (targetsByName.ContainsKey (index))
+                                       return targetsByName [index];
+                               else
+                                       return null;
                        }
                }
        }