Forgot this in changelog
[mono.git] / mcs / class / Microsoft.Build.Engine / Microsoft.Build.BuildEngine / TargetCollection.cs
index 4c9722f1699c27e2e2343cda1113a301cb4a56e2..8089806ef43a6df9cb6bd56f03658e40a68db2dd 100644 (file)
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
+#if NET_2_0
+
 using System;
 using System.Collections;
+using System.Collections.Generic;
 using System.Reflection;
 
 namespace Microsoft.Build.BuildEngine {
-       public class TargetCollection : ITargetCollection, ICollection, IEnumerable {
+       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.
+               [MonoTODO]
                public Target AddNewTarget (string targetName)
                {
-                       Target t;
-                       
-                       t = new Target (parentProject, targetName);
-                       targetsByName.Add (targetName, t);
-                       
-                       return t;
+                       throw new NotImplementedException ();
                }
 
-               public void CopyTo (Array array, int index)
+               internal void AddTarget (Target target)
                {
-                       targetsByName.Values.CopyTo (array, index);
+                       targetsByName.Add (target.Name, target);
                }
 
-               public void CopyToStronglyTypedArray (Target[] array,
-                                                     int index)
+               public void CopyTo (Array array, int index)
                {
-                       if (array == null)
-                               throw new ArgumentNullException ("array");
-                       if (index < 0)
-                               throw new ArgumentOutOfRangeException ("index");
-                       if (array.Rank > 1)
-                               throw new ArgumentException ("array is multidimensional");
-                       if ((array.Length > 0) && (index >= array.Length))
-                               throw new ArgumentException ("index is equal or greater than array.Length");
-                       if (index + targetsByName.Count > array.Length)
-                               throw new ArgumentException ("Not enough room from index to end of array for this BuildPropertyGroupCollection");
-               
-                       IEnumerator it = GetEnumerator ();
-                       int i = index;
-                       while (it.MoveNext ()) {
-                               array.SetValue((Target) it.Current, i++);
-                       }
+                       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)
@@ -112,10 +95,15 @@ 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;
                        }
                }
        }
 }
+
+#endif