/// <summary> /// Throws an exception. /// </summary> /// <param name="value">The object to convert to a string.</param> /// <param name="row">The <see cref="ICsvWriterRow"/> for the current record.</param> /// <param name="propertyMapData">The <see cref="CsvPropertyMapData"/> for the property/field being written.</param> /// <returns>The string representation of the object.</returns> public override string ConvertToString(object value, ICsvWriterRow row, CsvPropertyMapData propertyMapData) { var message = "Converting IEnumerable types is not supported for a single field. " + "If you want to do this, create your own ITypeConverter and register " + "it in the TypeConverterFactory by calling AddConverter."; throw new CsvTypeConverterException((WritingContext)row.Context, message); }
/// <summary> /// Converts the object to a string. /// </summary> /// <param name="value">The object to convert to a string.</param> /// <param name="row"></param> /// <param name="propertyMapData"></param> /// <returns>The string representation of the object.</returns> public override string ConvertToString( object value, ICsvWriterRow row, CsvPropertyMapData propertyMapData ) { var list = value as IEnumerable; if( list == null ) { return base.ConvertToString( value, row, propertyMapData ); } foreach( var item in list ) { row.WriteField( item.ToString() ); } return null; }
/// <summary> /// Converts the object to a string. /// </summary> /// <param name="value">The object to convert to a string.</param> /// <param name="row">The <see cref="ICsvWriterRow"/> for the current record.</param> /// <param name="propertyMapData">The <see cref="CsvPropertyMapData"/> for the property/field being written.</param> /// <returns>The string representation of the object.</returns> public override string ConvertToString( object value, ICsvWriterRow row, CsvPropertyMapData propertyMapData ) { var dictionary = value as IDictionary; if( dictionary == null ) { return base.ConvertToString( value, row, propertyMapData ); } foreach( DictionaryEntry entry in dictionary ) { row.WriteField( entry.Value ); } return null; }
/// <summary> /// Converts the object to a string. /// </summary> /// <param name="value">The object to convert to a string.</param> /// <param name="row">The <see cref="ICsvWriterRow"/> for the current record.</param> /// <param name="propertyMapData">The <see cref="CsvPropertyMapData"/> for the property/field being written.</param> /// <returns>The string representation of the object.</returns> public virtual string ConvertToString( object value, ICsvWriterRow row, CsvPropertyMapData propertyMapData ) { if( value == null ) { return string.Empty; } var formattable = value as IFormattable; if( formattable != null ) { return formattable.ToString( propertyMapData.TypeConverterOptions.Format, propertyMapData.TypeConverterOptions.CultureInfo ); } return value.ToString(); }
/// <summary> /// Converts the object to a string. /// </summary> /// <param name="value">The object to convert to a string.</param> /// <param name="row">The <see cref="ICsvWriterRow"/> for the current record.</param> /// <param name="propertyMapData">The <see cref="CsvPropertyMapData"/> for the property/field being written.</param> /// <returns>The string representation of the object.</returns> public override string ConvertToString(object value, ICsvWriterRow row, CsvPropertyMapData propertyMapData) { var dictionary = value as IDictionary; if (dictionary == null) { return(base.ConvertToString(value, row, propertyMapData)); } foreach (DictionaryEntry entry in dictionary) { row.WriteField(entry.Value); } return(null); }
/// <summary> /// Converts the object to a string. /// </summary> /// <param name="value">The object to convert to a string.</param> /// <param name="row"></param> /// <param name="propertyMapData"></param> /// <returns>The string representation of the object.</returns> public override string ConvertToString(object value, ICsvWriterRow row, CsvPropertyMapData propertyMapData) { var list = value as IEnumerable; if (list == null) { return(base.ConvertToString(value, row, propertyMapData)); } foreach (var item in list) { row.WriteField(item.ToString()); } return(null); }
/// <summary> /// Converts the object to a string. /// </summary> /// <param name="value">The object to convert to a string.</param> /// <param name="row">The <see cref="ICsvWriterRow"/> for the current record.</param> /// <param name="propertyMapData">The <see cref="CsvPropertyMapData"/> for the property/field being written.</param> /// <returns>The string representation of the object.</returns> public virtual string ConvertToString(object value, ICsvWriterRow row, CsvPropertyMapData propertyMapData) { if (value == null) { return(string.Empty); } var formattable = value as IFormattable; if (formattable != null) { return(formattable.ToString(propertyMapData.TypeConverterOptions.Format, propertyMapData.TypeConverterOptions.CultureInfo)); } return(value.ToString()); }
public string ConvertToString(object value, ICsvWriterRow row, CsvPropertyMapData propertyMapData) { return("test"); }
/// <summary> /// Throws an exception. /// </summary> /// <param name="value">The object to convert to a string.</param> /// <param name="row">The <see cref="ICsvWriterRow"/> for the current record.</param> /// <param name="propertyMapData">The <see cref="CsvPropertyMapData"/> for the property/field being written.</param> /// <returns>The string representation of the object.</returns> public override string ConvertToString( object value, ICsvWriterRow row, CsvPropertyMapData propertyMapData ) { throw new CsvTypeConverterException( "Converting IEnumerable types is not supported for a single field. " + "If you want to do this, create your own ITypeConverter and register " + "it in the TypeConverterFactory by calling AddConverter." ); }
/// <summary> /// Converts the object to a string. /// </summary> /// <param name="value">The object to convert to a string.</param> /// <param name="row"></param> /// <param name="propertyMapData"></param> /// <returns>The string representation of the object.</returns> public override string ConvertToString( object value, ICsvWriterRow row, CsvPropertyMapData propertyMapData ) { return UnderlyingTypeConverter.ConvertToString( value, row, propertyMapData ); }
/// <summary> /// Converts the object to a string. /// </summary> /// <param name="value">The object to convert to a string.</param> /// <param name="row"></param> /// <param name="propertyMapData"></param> /// <returns>The string representation of the object.</returns> public override string ConvertToString(object value, ICsvWriterRow row, CsvPropertyMapData propertyMapData) { return(UnderlyingTypeConverter.ConvertToString(value, row, propertyMapData)); }