/// <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);
        }
예제 #2
0
        /// <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;
        }
예제 #3
0
        /// <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;
        }
예제 #4
0
        /// <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();
        }
예제 #5
0
        /// <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);
        }
예제 #6
0
        /// <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);
        }
예제 #7
0
        /// <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());
        }
예제 #8
0
 public string ConvertToString(object value, ICsvWriterRow row, CsvPropertyMapData propertyMapData)
 {
     return("test");
 }
예제 #9
0
 /// <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." );
 }
예제 #10
0
 /// <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));
 }