/// <summary>
 /// 将自定义类型转换为指定类型
 /// </summary>
 /// <param name="context">当前上下文信息</param>
 /// <param name="culture">区域信息</param>
 /// <param name="value">要转换的System.Object。</param>
 /// <param name="destinationType">指定类型</param>
 /// <returns></returns>
 public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
 {
     //如果要转换为自定义类型
     if (destinationType == typeof(string))
     {
         if (value is CurrentRating)
         {
             CurrentRating current = (CurrentRating)value;
             return(string.Format("{0}({1})", current.Ib, current.Imax));
         }
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
 /// <summary>
 /// 将指定类型转换为自定义类型
 /// </summary>
 /// <param name="context">当前上下文信息</param>
 /// <param name="culture">区域信息</param>
 /// <param name="value">指定类型</param>
 /// <returns></returns>
 public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
 {
     if (value is string)
     {
         string        current           = (string)value;
         int           leftBracketIndex  = current.IndexOf('(');
         int           rightBracketIndex = current.IndexOf(')');
         CurrentRating cu = new CurrentRating();
         cu.Ib   = Convert.ToDecimal(current.Substring(0, leftBracketIndex));
         cu.Imax = Convert.ToDecimal(current.Substring(leftBracketIndex + 1, rightBracketIndex - leftBracketIndex - 1));
         return(cu);
     }
     return(base.ConvertFrom(context, culture, value));
 }