2
0
Эх сурвалжийг харах

2004-06-08 Umadevi S <[email protected]>
* DataColumnMappingCollection.cs - fixed nunit testcase errors.
- remove, removeat, contains methods.

svn path=/trunk/mcs/; revision=29022

Umadevi S 21 жил өмнө
parent
commit
eaabecc4bc

+ 4 - 0
mcs/class/System.Data/System.Data.Common/ChangeLog

@@ -1,3 +1,7 @@
+2004-06-08 Umadevi S <[email protected]>
+	* DataColumnMappingCollection.cs - fixed nunit testcase errors.
+	- remove, removeat, contains methods.
+
 2004-06-04  Gert Driesen <[email protected]>
 
 	* DataAdapter.cs: added missing protected ctor

+ 11 - 2
mcs/class/System.Data/System.Data.Common/DataColumnMappingCollection.cs

@@ -147,6 +147,8 @@ namespace System.Data.Common {
 
 		public bool Contains (object value) 
 		{
+			if  (!(value is DataColumnMapping))
+				throw new InvalidCastException("Object is not of type DataColumnMapping");
 			return (list.Contains (value));
 		}
 
@@ -157,7 +159,7 @@ namespace System.Data.Common {
 
 		public void CopyTo (Array array, int index) 
 		{
-			((DataColumn[])(list.ToArray())).CopyTo (array, index);
+		 	(list.ToArray()).CopyTo(array,index);
 		}
 
 		public DataColumnMapping GetByDataSetColumn (string value) 
@@ -224,13 +226,20 @@ namespace System.Data.Common {
 
 		public void Remove (object value) 
 		{
-			sourceColumns.Remove(((DataColumnMapping)value).SourceColumn);
+			int index = list.IndexOf (value);
+      			sourceColumns.Remove(((DataColumnMapping)value).SourceColumn);
 			dataSetColumns.Remove(((DataColumnMapping)value).DataSetColumn);
+			if (( index < 0 ) || (index >=list.Count))
+                                    throw new ArgumentException("There is no such element in collection.");
+
 			list.Remove (value);
 		}
 
 		public void RemoveAt (int index) 
 		{
+			if (( index < 0 ) || (index >=list.Count))
+                                    throw new IndexOutOfRangeException("There is no element in collection.");
+
 			Remove (list[index]);
 		}