return ((InstanceDescriptor) value).Invoke ();
}
- throw new NotSupportedException (this.ToString() + " cannot be created from '" +
- value.GetType().ToString() + "'");
+ return GetConvertFromException (value);
}
public object ConvertFromInvariantString (string text)
return String.Empty;
}
- throw new NotSupportedException ("Conversion not supported");
+ return GetConvertToException (value, destinationType);
}
public string ConvertToInvariantString (object value)
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)
public PropertyDescriptorCollection GetProperties (ITypeDescriptorContext context, object value)
{
- return GetProperties (context, value, null);
+ return GetProperties (context, value, new Attribute[1] { BrowsableAttribute.Yes });
}
public virtual PropertyDescriptorCollection GetProperties (ITypeDescriptorContext context,
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 ();