public override ExtractStatus Extract(TextFileReader reader) { string valueString = null; try { valueString = reader.GetCSVFieldValue(this.ColumnNo); this.Value = this.FieldType.ConvertFromString(valueString); } catch (Exception exc) { throw new Exception(this.FieldInfo + ": \"" + valueString + "\": " + exc.ToString()); } ExtractStatus r = ExtractStatus.Success; if (null == this.InstanceCreator) { if (this.Value.Equals(SignatureValue)) { this.Target = new T(); r = ExtractStatus.Success; } else { r = ExtractStatus.ValueMismatched; } } else { this.Target = this.InstanceCreator(this, this.Value); } return(r); }
public override ExtractStatus Import(String filePath, out T t) { TextFileReader reader = new TextFileReader(filePath); reader.FieldDelimiterChar = this.FieldDelimiterChar; t = null; ExtractStatus r = ExtractStatus.Success; try { if (null != base.OnImportStartHandler) { base.OnImportStartHandler(filePath, t); } r = this.RecordMapping.Import(reader); t = this.RecordMapping.Target; reader.Close(); if (null != base.OnImportFinishHandler) { base.OnImportFinishHandler(filePath, t); } } catch (Exception exc) { reader.Close();//by kittikun 2014-10-11 if (!(exc is EndOfStreamException)) { throw exc; } } return(r); }
public override ExtractStatus Extract(TextFileReader reader) { if (null == this.SignatureMapper) { throw new Exception(this.FieldInfo + " - Signature field mapper is empty."); } ExtractStatus r = this.SignatureMapper.Extract(reader); if (r != ExtractStatus.Success) { return(r); } this.Value = this.SignatureMapper.Target; if (this.Value == null) { if (this.IsMandatory) { throw new Exception(this.FieldInfo + " - Mandatory field is empty."); } r = ExtractStatus.Success; } else { if (null != this.PropertySetter) { this.PropertySetter(this, this.Target, this.Value); } r = base.ExtractValues(this.Value, reader); } return(r); }
public override ExtractStatus Extract(TextFileReader reader) { V v = new V(); if (null != this.PropertySetter) { this.PropertySetter(this, this.Target, v); } return(ExtractValues(v, reader)); }
public override ExtractStatus Extract(TextFileReader reader) { string valueString = null; try { valueString = this.ExtractTrimSubstring(reader.RecordBuffer); this.Value = this.FieldType.ConvertFromString(valueString); return(null == this.PropertySetter ? ExtractStatus.Success : this.PropertySetter(this, this.Target, this.Value)); } catch (Exception exc) { throw new Exception(this.FieldInfo + ": \"" + valueString + "\" : " + exc.ToString()); } }
public virtual ExtractStatus ExtractValues(V v, TextFileReader reader) { ExtractStatus r = ExtractStatus.Success; if (null != this.FieldMappers) { foreach (FixedLengthFieldMapper <V> f in this.FieldMappers) { f.Target = v; r = f.Extract(reader); if (r != ExtractStatus.Success) { break; } } } return(r); }
/// <summary> /// Import records to create an instance of T that would be put in the property Value. /// </summary> /// <param name="reader"></param> /// <returns></returns> public override ExtractStatus Import(TextFileReader reader) { this.HeaderMapper.Value = null; reader.Next(); ExtractStatus r = this.HeaderMapper.Extract(reader); if (r != ExtractStatus.Success) { return(r); } this.Target = this.DetailMapper.Target = this.FooterMapper.Value = this.HeaderMapper.Value; r = this.DetailMapper.Import(reader); if (r == ExtractStatus.Success) { reader.Next(); r = this.FooterMapper.Extract(reader); } return(r); }
public override IList <T> Import(String filePath) { TextFileReader reader = new TextFileReader(filePath); IList <T> instances = new List <T>(); T t = null; ExtractStatus r = ExtractStatus.Success; //while (true) //{ try { r = this.RecordMapping.Import(reader); } catch (Exception exc) { if (!(exc is EndOfStreamException)) { throw exc; } } //} instances.Add(t); return(instances); }
public override ExtractStatus Import(TextFileReader reader) { return(this.Import <T, V>(reader)); }
public abstract ExtractStatus Import(TextFileReader reader);
public virtual ExtractStatus Extract(TextFileReader reader) { return(this.Extract <V>(reader)); }
public virtual ExtractStatus Extract(TextFileReader reader) { return(this.MultiFieldMapper.Extract(reader)); }