private static IValue CloneValue(this IValue source, IColumn column) { switch (column.Type) { case ColumnType.Date: if (source.GetValueType() == typeof(DateTime)) { return(new ValueWrapper <DateTime>().Assign(source)); } return(column.GetDateTimeParser()(source.ToString())); case ColumnType.Decimal: case ColumnType.Money: if (source.GetValueType() == typeof(decimal)) { return(new ValueWrapper <decimal>().Assign(source)); } return(column.GetDecimalParser()(source.ToString())); case ColumnType.Integer: if (source.GetValueType() == typeof(long)) { return(new ValueWrapper <long>().Assign(source)); } return(column.GetIntegerParser()(source.ToString())); case ColumnType.String: return(new ValueWrapper <string>(source.ToString(column.Format), source.GetError(), source.IsNull, source.Source)); } return(null); }
public IValue Assign(IValue value) { this.Value = value is IValue <T> tValue ? tValue.GetValue() : throw new ImporterArgumentOutOfRangeException( Localization.GetLocalizationString("Cannot assign \"{0}\" to \"{1}\"", value.GetValueType().Name, typeof(T).Name)); this.Source = value.Source; this.Error = value.GetError(); this.IsNull = value.IsNull; return(this); }