private IDataReader AsDataReader(Action <IDictionary <string, Type> > membersDiscovered) { if (_jObjects == null) { ChoJSONRecordReader rr = new ChoJSONRecordReader(typeof(T), Configuration); if (_textReader != null) { _JSONReader = new JsonTextReader(_textReader); } rr.Reader = this; rr.TraceSwitch = TraceSwitch; rr.RowsLoaded += NotifyRowsLoaded; rr.MembersDiscovered += membersDiscovered != null ? (o, e) => membersDiscovered(e.Value) : MembersDiscovered; var dr = new ChoEnumerableDataReader(rr.AsEnumerable(_JSONReader), rr); return(dr); } else { ChoJSONRecordReader rr = new ChoJSONRecordReader(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(rr.AsEnumerable(_jObjects), rr); return(dr); } }
public IDataReader AsDataReader() { if (_jObjects == null) { ChoJSONRecordReader rr = new ChoJSONRecordReader(typeof(T), Configuration); if (_textReader != null) { _JSONReader = new JsonTextReader(_textReader); } rr.Reader = this; rr.TraceSwitch = TraceSwitch; rr.RowsLoaded += NotifyRowsLoaded; var dr = new ChoEnumerableDataReader(rr.AsEnumerable(_JSONReader), rr); return(dr); } else { ChoJSONRecordReader rr = new ChoJSONRecordReader(typeof(T), Configuration); rr.Reader = this; rr.TraceSwitch = TraceSwitch; rr.RowsLoaded += NotifyRowsLoaded; var dr = new ChoEnumerableDataReader(rr.AsEnumerable(_jObjects), rr); return(dr); } }
//internal static IEnumerator<object> LoadText(Type recType, string inputText, ChoJSONRecordConfiguration configuration, Encoding encoding, int bufferSize) //{ // ChoJSONRecordReader rr = new ChoJSONRecordReader(recType, configuration); // rr.TraceSwitch = ChoETLFramework.TraceSwitchOff; // return rr.AsEnumerable(new StreamReader(inputText.ToStream(), encoding, false, bufferSize)).GetEnumerator(); //} public IEnumerator <T> GetEnumerator() { if (_jObjects == null) { ChoJSONRecordReader rr = new ChoJSONRecordReader(typeof(T), Configuration); if (_textReader != null) { _JSONReader = new JsonTextReader(_textReader); } rr.Reader = this; rr.TraceSwitch = TraceSwitch; rr.RowsLoaded += NotifyRowsLoaded; rr.MembersDiscovered += MembersDiscovered; var e = rr.AsEnumerable(_JSONReader).GetEnumerator(); return(ChoEnumeratorWrapper.BuildEnumerable <T>(() => e.MoveNext(), () => (T)ChoConvert.ChangeType <ChoRecordFieldAttribute>(e.Current, typeof(T)), () => Dispose()).GetEnumerator()); } else { ChoJSONRecordReader rr = new ChoJSONRecordReader(typeof(T), Configuration); rr.Reader = this; rr.TraceSwitch = TraceSwitch; rr.RowsLoaded += NotifyRowsLoaded; rr.MembersDiscovered += MembersDiscovered; var e = rr.AsEnumerable(_jObjects).GetEnumerator(); return(ChoEnumeratorWrapper.BuildEnumerable <T>(() => e.MoveNext(), () => (T)ChoConvert.ChangeType <ChoRecordFieldAttribute>(e.Current, typeof(T)), () => Dispose()).GetEnumerator()); } }
internal static IEnumerator <object> LoadText(Type recType, string inputText, ChoJSONRecordConfiguration configuration, Encoding encoding, int bufferSize) { ChoJSONRecordReader rr = new ChoJSONRecordReader(recType, configuration); rr.TraceSwitch = ChoETLFramework.TraceSwitchOff; return(rr.AsEnumerable(new StreamReader(inputText.ToStream(), encoding, false, bufferSize)).GetEnumerator()); }