internal static IEnumerator <object> LoadText(Type recType, string inputText, ChoFixedLengthRecordConfiguration configuration, Encoding encoding, int bufferSize, TraceSwitch traceSwitch = null) { ChoFixedLengthRecordReader rr = new ChoFixedLengthRecordReader(recType, configuration); rr.TraceSwitch = traceSwitch == null ? ChoETLFramework.TraceSwitchOff : traceSwitch; return(rr.AsEnumerable(new StreamReader(inputText.ToStream(), encoding, false, bufferSize)).GetEnumerator()); }
public IEnumerator <T> GetEnumerator() { ChoFixedLengthRecordReader reader = new ChoFixedLengthRecordReader(typeof(T), Configuration); var e = reader.AsEnumerable(_streamReader).GetEnumerator(); return(ChoEnumeratorWrapper.BuildEnumerable <T>(() => e.MoveNext(), () => (T)ChoConvert.ChangeType <ChoRecordFieldAttribute>(e.Current, typeof(T))).GetEnumerator()); }
public IDataReader AsDataReader() { ChoFixedLengthRecordReader reader = new ChoFixedLengthRecordReader(typeof(T), Configuration); reader.LoadSchema(_streamReader); var dr = new ChoEnumerableDataReader(GetEnumerator().ToEnumerable(), Configuration.FixedLengthRecordFieldConfigurations.Select(i => new KeyValuePair <string, Type>(i.Name, i.FieldType)).ToArray()); return(dr); }
public IDataReader AsDataReader() { ChoFixedLengthRecordReader rr = new ChoFixedLengthRecordReader(typeof(T), Configuration); rr.Reader = this; rr.TraceSwitch = TraceSwitch; rr.RowsLoaded += NotifyRowsLoaded; var dr = new ChoEnumerableDataReader(rr.AsEnumerable(_textReader), rr); return(dr); }
public IEnumerator <T> GetEnumerator() { ChoFixedLengthRecordReader rr = new ChoFixedLengthRecordReader(typeof(T), Configuration); rr.Reader = this; rr.TraceSwitch = TraceSwitch; rr.RowsLoaded += NotifyRowsLoaded; var e = rr.AsEnumerable(_textReader).GetEnumerator(); return(ChoEnumeratorWrapper.BuildEnumerable <T>(() => e.MoveNext(), () => (T)ChoConvert.ChangeType <ChoRecordFieldAttribute>(e.Current, typeof(T))).GetEnumerator()); }
private IDataReader AsDataReader(Action <IDictionary <string, Type> > membersDiscovered) { ChoFixedLengthRecordReader rr = new ChoFixedLengthRecordReader(typeof(T), Configuration); rr.Reader = this; rr.TraceSwitch = TraceSwitch; rr.RowsLoaded += NotifyRowsLoaded; rr.MembersDiscovered += membersDiscovered != null ? (o, e) => membersDiscovered(e.Value) : MembersDiscovered; var dr = new ChoEnumerableDataReader(_lines != null ? rr.AsEnumerable(_lines) : rr.AsEnumerable(_textReader), rr); return(dr); }
public IEnumerator <T> GetEnumerator() { ChoFixedLengthRecordReader rr = new ChoFixedLengthRecordReader(typeof(T), Configuration); rr.Reader = this; rr.TraceSwitch = TraceSwitch; rr.RowsLoaded += NotifyRowsLoaded; rr.MembersDiscovered += MembersDiscovered; rr.RecordFieldTypeAssessment += RecordFieldTypeAssessment; var e = _lines != null?rr.AsEnumerable(_lines).GetEnumerator() : rr.AsEnumerable(_textReader).GetEnumerator(); return(ChoEnumeratorWrapper.BuildEnumerable <T>(() => e.MoveNext(), () => (T)ChoConvert.ChangeType <ChoRecordFieldAttribute>(e.Current, typeof(T)), () => Dispose()).GetEnumerator()); }