2 * Namespace: System.Web.UI.WebControls
\r
3 * Class: FontNamesConverter
\r
5 * Author: Gaurav Vaish
\r
6 * Maintainer: gvaish@iitk.ac.in
\r
7 * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
\r
8 * Implementation: yes
\r
11 * (C) Gaurav Vaish (2002)
\r
15 using System.ComponentModel;
\r
17 using System.Web.UI;
\r
19 namespace System.Web.UI.WebControls
\r
21 public class FontNamesConverter : TypeConverter
\r
23 public FontNamesConverter(): base()
\r
27 public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
\r
29 return (sourceType == typeof(string));
\r
32 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
\r
36 string fontNames = (string)value;
\r
37 if(fontNames.Length == 0)
\r
39 return (new string[0]);
\r
41 string[] names = fontNames.Split(new char[] { ','});
\r
42 foreach(string current in names)
\r
44 current = current.Trim();
\r
48 throw GetConvertFromException(value);
\r
51 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
\r
53 if(destinationType is typeof(string))
\r
55 if(value == null || ((string[])value) == null)
\r
56 return String.Empty;
\r
57 return String.Join(",", (string[])value);
\r
59 throw GetConvertToException(value, destinationType);
\r