CollectionConverter.cs 1018 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // System.ComponentModel.CollectionConverter
  3. //
  4. // Authors:
  5. // Martin Willemoes Hansen ([email protected])
  6. // Andreas Nahr ([email protected])
  7. //
  8. // (C) 2003 Martin Willemoes Hansen
  9. // (C) 2003 Andreas Nahr
  10. //
  11. using System.Collections;
  12. using System.Globalization;
  13. namespace System.ComponentModel
  14. {
  15. public class CollectionConverter : TypeConverter
  16. {
  17. public CollectionConverter()
  18. {
  19. }
  20. public override object ConvertTo (ITypeDescriptorContext context,
  21. CultureInfo culture, object value, Type destinationType)
  22. {
  23. if (destinationType == typeof (string))
  24. if (value != null && (value is ICollection))
  25. return "(Collection)";
  26. return base.ConvertTo (context, culture, value, destinationType);
  27. }
  28. public override PropertyDescriptorCollection GetProperties (ITypeDescriptorContext context,
  29. object value, Attribute[] attributes)
  30. {
  31. return null;
  32. }
  33. public override bool GetPropertiesSupported (ITypeDescriptorContext context)
  34. {
  35. return false;
  36. }
  37. }
  38. }