Esempio n. 1
0
        private string[] readNextLine()
        {
            string record = reader.ReadRecord();

            if (record.Length != schema.TotalWidth)
            {
                hasError = true;
                throw new FlatFileException(recordCount);
            }
            string[] values = new string[schema.ColumnDefinitions.Count];
            int      offset = 0;

            for (int index = 0; index != values.Length; ++index)
            {
                Window window = schema.Windows[index];
                string value  = record.Substring(offset, window.Width);
                if (window.Alignment == FixedAlignment.LeftAligned)
                {
                    value = value.TrimEnd(window.FillCharacter ?? options.FillCharacter);
                }
                else
                {
                    value = value.TrimStart(window.FillCharacter ?? options.FillCharacter);
                }
                values[index] = value;
                offset       += window.Width;
            }
            return(values);
        }
        private string[] readNextRecord()
        {
            string record     = reader.ReadRecord();
            Match  match      = regex.Match(record);
            Group  blockGroup = match.Groups["block"];

            string[] values = blockGroup.Captures.Cast <Capture>().Select(c => c.Value).ToArray();
            return(values);
        }