Esempio n. 1
0
        public IEnumerator <T> GetEnumerator()
        {
            CheckDisposed();
            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.Value).GetEnumerator();

            return(ChoEnumeratorWrapper.BuildEnumerable <T>(() => e.MoveNext(), () => (T)ChoConvert.ChangeType <ChoRecordFieldAttribute>(e.Current, typeof(T)), () => Dispose()).GetEnumerator());
        }
Esempio n. 2
0
        public IEnumerator <T> GetEnumerator()
        {
            ChoKVPRecordReader rr = new ChoKVPRecordReader(typeof(T), Configuration);

            rr.Reader             = this;
            rr.TraceSwitch        = TraceSwitch;
            rr.RowsLoaded        += NotifyRowsLoaded;
            rr.MembersDiscovered += MembersDiscovered;
            var e = rr.AsEnumerable(_textReader).GetEnumerator();

            return(ChoEnumeratorWrapper.BuildEnumerable <T>(() => e.MoveNext(), () => (T)ChoConvert.ChangeType <ChoRecordFieldAttribute>(e.Current, typeof(T))).GetEnumerator());
        }
Esempio n. 3
0
        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());
        }
Esempio n. 4
0
        public IEnumerator <T> GetEnumerator()
        {
            if (_jObjects == null)
            {
                ChoJSONRecordReader rr = new ChoJSONRecordReader(typeof(T), Configuration);
                if (_textReader != null)
                {
                    _JSONReader = Create(_textReader);
                }

                rr.Reader                     = this;
                rr.TraceSwitch                = TraceSwitch;
                rr.RowsLoaded                += NotifyRowsLoaded;
                rr.MembersDiscovered         += MembersDiscovered;
                rr.RecordFieldTypeAssessment += RecordFieldTypeAssessment;
                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;
                rr.RecordFieldTypeAssessment += RecordFieldTypeAssessment;
                var e = rr.AsEnumerable(_jObjects).GetEnumerator();
                return(ChoEnumeratorWrapper.BuildEnumerable <T>(() => e.MoveNext(), () => (T)ChoConvert.ChangeType <ChoRecordFieldAttribute>(e.Current, typeof(T)), () => Dispose()).GetEnumerator());
            }
        }
Esempio n. 5
0
        //internal static IEnumerator<object> LoadText(Type recType, string inputText, ChoXmlRecordConfiguration configuration, Encoding encoding, int bufferSize, TraceSwitch traceSwitch = null)
        //{
        //    ChoXmlRecordReader rr = new ChoXmlRecordReader(recType, configuration);
        //    rr.TraceSwitch = traceSwitch == null ? ChoETLFramework.TraceSwitchOff : traceSwitch;
        //    return rr.AsEnumerable(new StreamReader(inputText.ToStream(), encoding, false, bufferSize)).GetEnumerator();
        //}

        public IEnumerator <T> GetEnumerator()
        {
            if (_xElements == null)
            {
                ChoXmlRecordReader rr = new ChoXmlRecordReader(typeof(T), Configuration);
                if (_textReader != null)
                {
                    _xmlReader = XmlReader.Create(_textReader, new XmlReaderSettings(), new XmlParserContext(null, Configuration.NamespaceManager, null, XmlSpace.None));
                }

                rr.Reader      = this;
                rr.TraceSwitch = TraceSwitch;
                rr.RowsLoaded += NotifyRowsLoaded;
                var e = rr.AsEnumerable(_xmlReader).GetEnumerator();
                return(ChoEnumeratorWrapper.BuildEnumerable <T>(() => e.MoveNext(), () => (T)ChoConvert.ChangeType <ChoRecordFieldAttribute>(e.Current, typeof(T))).GetEnumerator());
            }
            else
            {
                ChoXmlRecordReader rr = new ChoXmlRecordReader(typeof(T), Configuration);

                rr.Reader      = this;
                rr.TraceSwitch = TraceSwitch;
                rr.RowsLoaded += NotifyRowsLoaded;
                var e = rr.AsEnumerable(_xElements).GetEnumerator();
                return(ChoEnumeratorWrapper.BuildEnumerable <T>(() => e.MoveNext(), () => (T)ChoConvert.ChangeType <ChoRecordFieldAttribute>(e.Current, typeof(T))).GetEnumerator());
            }
        }