Ejemplo n.º 1
0
 internal static TypeConverter GetToStringConverter(this Type type)
 {
     TypeConverter typeConverter = TypeDescriptor.GetConverter(type);
     if (typeConverter is DateTimeConverter)
     {
         //replace default datetime converter for serializing datetime in ISO 8601 format
         typeConverter = new DateTimeConverterISO8601();
     }
     if (typeConverter != null && !typeConverter.CanConvertTo(typeof(String)))
     {
         typeConverter = null;
     }
     return typeConverter;
 }
Ejemplo n.º 2
0
        internal static TypeConverter GetToStringConverter(this Type type)
        {
            TypeConverter typeConverter = TypeDescriptor.GetConverter(type);

            if (typeConverter is DateTimeConverter)
            {
                //replace default datetime converter for serializing datetime in ISO 8601 format
                typeConverter = new DateTimeConverterISO8601();
            }
            if (typeConverter != null && !typeConverter.CanConvertTo(typeof(String)))
            {
                typeConverter = null;
            }
            return(typeConverter);
        }