for TARGET_J2EE only:
[mono.git] / mcs / class / System / System.ComponentModel / TypeConverter.cs
index 51aef0ed10433319beffaf6d96c589ae738dada7..419764a28e36a7c0b4f0368538da67b4b62c6af1 100644 (file)
@@ -76,8 +76,7 @@ namespace System.ComponentModel
                                return ((InstanceDescriptor) value).Invoke ();
                        }
 
-                       throw new NotSupportedException (this.ToString() + " cannot be created from '" +
-                                                        value == null ? "null" : value.GetType().ToString() + "'");
+                       return GetConvertFromException (value);
                }
 
                public object ConvertFromInvariantString (string text)
@@ -123,7 +122,7 @@ namespace System.ComponentModel
                                return String.Empty;
                        }
 
-                       throw new NotSupportedException ("Conversion not supported");
+                       return GetConvertToException (value, destinationType);
                }
 
                public string ConvertToInvariantString (object value)
@@ -153,14 +152,28 @@ namespace System.ComponentModel
 
                protected Exception GetConvertFromException (object value)
                {
-                       throw new NotSupportedException (this.ToString() + " cannot convert from '" + 
-                                                       value.GetType().ToString() + "'");
+                       string destinationType;
+                       if (value == null)
+                               destinationType = "(null)";
+                       else
+                               destinationType = value.GetType ().FullName;
+
+                       throw new NotSupportedException (string.Format (CultureInfo.InvariantCulture,
+                               "{0} cannot convert from {1}.", this.GetType ().Name,
+                               destinationType));
                }
 
                protected Exception GetConvertToException (object value, Type destinationType)
                {
-                       throw new NotSupportedException (this.ToString() + " cannot convert from '" + 
-                                                       value.GetType().ToString() + "' to '" + destinationType.ToString() + "'");
+                       string sourceType;
+                       if (value == null)
+                               sourceType = "(null)";
+                       else
+                               sourceType = value.GetType ().FullName;
+
+                       throw new NotSupportedException (string.Format (CultureInfo.InvariantCulture,
+                               "'{0}' is unable to convert '{1}' to '{2}'.", this.GetType ().Name,
+                               sourceType, destinationType.FullName));
                }
 
                public object CreateInstance (IDictionary propertyValues)
@@ -264,11 +277,19 @@ namespace System.ComponentModel
                                this.values = values;
                        }
 
+                       void ICollection.CopyTo (Array array, int index) {
+                               CopyTo (array, index);
+                       }
+
                        public void CopyTo (Array array, int index)
                        {
                                values.CopyTo (array, index);
                        }
 
+                       IEnumerator IEnumerable.GetEnumerator () {
+                               return GetEnumerator ();
+                       }
+
                        public IEnumerator GetEnumerator ()
                        {
                                return values.GetEnumerator ();