コード例 #1
0
        public ChoFixedLengthReader(Stream inStream, ChoFixedLengthRecordConfiguration configuration = null)
        {
            ChoGuard.ArgumentNotNull(inStream, "Stream");

            Configuration = configuration;
            Init();

            if (inStream is MemoryStream)
            {
                _textReader = new Lazy <TextReader>(() => new StreamReader(inStream));
            }
            else
            {
                _textReader = new Lazy <TextReader>(() =>
                {
                    if (Configuration.DetectEncodingFromByteOrderMarks == null)
                    {
                        return(new StreamReader(inStream, Configuration.GetEncoding(inStream), false, Configuration.BufferSize));
                    }
                    else
                    {
                        return(new StreamReader(inStream, Encoding.Default, Configuration.DetectEncodingFromByteOrderMarks.Value, Configuration.BufferSize));
                    }
                });
            }
            //_closeStreamOnDispose = true;
        }
コード例 #2
0
        public ChoFixedLengthReader(Stream inStream, ChoFixedLengthRecordConfiguration configuration = null)
        {
            ChoGuard.ArgumentNotNull(inStream, "Stream");

            Configuration = configuration;
            Init();
            _textReader           = new StreamReader(inStream, Configuration.GetEncoding(inStream), false, Configuration.BufferSize);
            _closeStreamOnDispose = true;
        }
コード例 #3
0
        public ChoFixedLengthReader(string filePath, ChoFixedLengthRecordConfiguration configuration = null)
        {
            ChoGuard.ArgumentNotNullOrEmpty(filePath, "FilePath");

            Configuration = configuration;

            Init();

            _textReader           = new StreamReader(ChoPath.GetFullPath(filePath), Configuration.GetEncoding(filePath), false, Configuration.BufferSize);
            _closeStreamOnDispose = true;
        }
コード例 #4
0
        public ChoFixedLengthReader(Stream inStream, ChoFixedLengthRecordConfiguration configuration = null)
        {
            ChoGuard.ArgumentNotNull(inStream, "Stream");

            Configuration = configuration;
            Init();

            if (inStream is MemoryStream)
            {
                _textReader = new Lazy <TextReader>(() => new StreamReader(inStream));
            }
            else
            {
                _textReader = new Lazy <TextReader>(() => new StreamReader(inStream, Configuration.GetEncoding(inStream), false, Configuration.BufferSize));
            }
            //_closeStreamOnDispose = true;
        }
コード例 #5
0
        public ChoFixedLengthReader(string filePath, ChoFixedLengthRecordConfiguration configuration = null)
        {
            ChoGuard.ArgumentNotNullOrEmpty(filePath, "FilePath");

            Configuration = configuration;

            Init();

            _textReader = new Lazy <TextReader>(() =>
            {
                if (Configuration.LiteParsing && !Configuration.TurnOffMemoryMappedFile)
                {
                    _memoryMappedFile = MemoryMappedFile.CreateFromFile(filePath);
                    return(new StreamReader(_memoryMappedFile.CreateViewStream(0, 0, MemoryMappedFileAccess.Read)));
                }
                else
                {
                    return(new StreamReader(filePath, Configuration.GetEncoding(filePath), false, Configuration.BufferSize));
                }
            });
            _closeStreamOnDispose = true;
        }