2007-07-22 Nagappan A <anagappan@novell.com>
[mono.git] / mcs / class / System.Data / System.Data.Common / DataTableMappingCollection.cs
index 716e49beaf5874b60daab6a65497cdb8a6b72ef3..6b80997fe14d061f825ccfec987e8d706f89c83e 100644 (file)
@@ -63,14 +63,18 @@ namespace System.Data.Common {
                #region Properties
 
                [Browsable (false)]
+#if !NET_2_0
                [DataSysDescription ("The number of items in the collection")]
+#endif
                [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
                public int Count {
                        get { return mappings.Count; }
                }
 
                [Browsable (false)]
+#if !NET_2_0
                [DataSysDescription ("The specified DataTableMapping object")]
+#endif
                [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
                public DataTableMapping this [int index] {
                        get { return (DataTableMapping)(mappings[index]); }
@@ -83,7 +87,9 @@ namespace System.Data.Common {
                }
 
                [Browsable (false)]
+#if !NET_2_0
                [DataSysDescription ("The specified DataTableMapping object")]
+#endif
                [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
                public DataTableMapping this [string sourceTable] {
                        get { return (DataTableMapping) sourceTables[sourceTable]; }
@@ -146,10 +152,10 @@ namespace System.Data.Common {
                }
 
 #if NET_2_0
-               [MonoTODO]
                public void AddRange (Array values)
                {
-                       throw new NotImplementedException ();
+                       for (int i = 0; i < values.Length; ++i)
+                               Add (values.GetValue (i));
                }
 #endif
 
@@ -181,6 +187,13 @@ namespace System.Data.Common {
                        mappings.CopyTo (array, index);
                }
 
+#if NET_2_0
+               public void CopyTo (DataTableMapping[] array, int index) 
+               {
+                       mappings.CopyTo (array, index);
+               }
+#endif
+
                public DataTableMapping GetByDataSetTable (string dataSetTable) 
                {
                        
@@ -207,7 +220,8 @@ namespace System.Data.Common {
                        if (tableMappings.Contains (sourceTable))
                                return tableMappings[sourceTable];
                        if (mappingAction == MissingMappingAction.Error)
-                               throw new InvalidOperationException ();
+                               throw new InvalidOperationException (String.Format ("Missing source table mapping: '{0}'",
+                                                                                   sourceTable));
                        if (mappingAction == MissingMappingAction.Ignore)
                                return null;
                        return new DataTableMapping (sourceTable, dataSetTable);
@@ -257,6 +271,15 @@ namespace System.Data.Common {
                         dataSetTables[((DataTableMapping)value).DataSetTable] = value;
                }
 
+#if NET_2_0
+               public void Insert (int index, DataTableMapping value) 
+               {
+                       mappings.Insert (index, value);
+                       sourceTables[value.SourceTable] = value;
+                        dataSetTables[value.DataSetTable] = value;
+               }
+#endif
+
                ITableMapping ITableMappingCollection.Add (string sourceTableName, string dataSetTableName)
                {
                        ITableMapping tableMapping = new DataTableMapping (sourceTableName, dataSetTableName);
@@ -275,10 +298,19 @@ namespace System.Data.Common {
                                  throw new InvalidCastException ();
                        int index = mappings.IndexOf (value);
                        if (( index < 0 ) || (index >=mappings.Count))
-                                    throw new ArgumentException("There is no such element in collection.");                                                                                 
+                                    throw new ArgumentException("There is no such element in collection.");
+                       mappings.Remove ((DataTableMapping) value);
+               }
 
+#if NET_2_0
+               public void Remove (DataTableMapping value) 
+               {
+                       int index = mappings.IndexOf (value);
+                       if (( index < 0 ) || (index >=mappings.Count))
+                                    throw new ArgumentException("There is no such element in collection."); 
                        mappings.Remove ((DataTableMapping) value);
                }
+#endif
 
                public void RemoveAt (int index) 
                {