Implementation of the 2.0 session state model
[mono.git] / mcs / class / Microsoft.Build.Engine / Microsoft.Build.BuildEngine / ImportCollection.cs
index 410cd660940c893ac8e20400814060cd17398e3e..e1ad261c903f2e65b5ddf804734a630089604fd1 100644 (file)
@@ -36,46 +36,50 @@ using System.Xml;
 namespace Microsoft.Build.BuildEngine {
        public class ImportCollection : ICollection, IEnumerable {
                
-               List <Import>   imports;
-               //Project               parentProject;
+               GroupingCollection groupingCollection;
                
-               internal ImportCollection (Project parentProject)
+               internal ImportCollection (GroupingCollection groupingCollection)
                {
-               //      this.parentProject = parentProject;
-                       this.imports = new List <Import> ();
+                       this.groupingCollection = groupingCollection;
                }
                
                internal void Add (Import import)
                {
-                       if (import == null)
-                               throw new ArgumentNullException ("import");
-                       
-                       if (imports.Contains (import))
-                               throw new InvalidOperationException ("Import already added.");
-                       
-                       imports.Add (import);
+                       groupingCollection.Add (import);
                }
                
-               [MonoTODO]
                public void CopyTo (Array array, int index)
                {
-                       throw new NotImplementedException ();
+                       if (array == null)
+                               throw new ArgumentNullException ("array");
+                       if (index < 0)
+                               throw new ArgumentOutOfRangeException ("Index was outside the bounds of the array.");
+                       if (array.Rank > 1)
+                               throw new ArgumentException ("array is multidimensional");
+                       if ((array.Length > 0) && (index >= array.Length))
+                               throw new ArgumentException ("Index was outside the bounds of the array.");
+                       if (index + this.Count > array.Length)
+                               throw new ArgumentException ("Not enough room from index to end of array for this BuildItemGroupCollection");
+
+                       IEnumerator it = GetEnumerator ();
+                       int i = index;
+                       while (it.MoveNext ()) {
+                               array.SetValue(it.Current, i++);
+                       }
                }
                
-               [MonoTODO]
                public void CopyTo (Import[] array, int index)
                {
-                       throw new NotImplementedException ();
+                       CopyTo ((Array) array, index);
                }
                
                public IEnumerator GetEnumerator ()
                {
-                       foreach (Import i in imports)
-                               yield return i;
+                       return groupingCollection.GetImportEnumerator ();
                }
                
                public int Count {
-                       get { return imports.Count; }
+                       get { return groupingCollection.Imports; }
                }
                
                public bool IsSynchronized  {
@@ -83,7 +87,7 @@ namespace Microsoft.Build.BuildEngine {
                }
                
                public object SyncRoot {
-                       get { return this; }
+                       get { return null; }
                }
        }
 }