コード例 #1
0
 // Overrides the ConvertFrom method of TypeConverter.
 public override object ConvertFrom(ITypeDescriptorContext context,
                                    CultureInfo culture, object value)
 {
     if (value is string)
     {
         return(PersianDate.Parse(value as string));
     }
     if (value is DateTime)
     {
         return(new PersianDate((DateTime)value));
     }
     return(base.ConvertFrom(context, culture, value));
 }
コード例 #2
0
 // Overrides the ConvertTo method of TypeConverter.
 public override object ConvertTo(ITypeDescriptorContext context,
                                  CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType == typeof(string))
     {
         PersianDate pd = (PersianDate)value;
         return(value.ToString());
     }
     if (destinationType == typeof(DateTime))
     {
         PersianDate pd = (PersianDate)value;
         return(pd.ToDateTime());
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }