コード例 #1
0
        public override async Task <ExpandoObject[]> ReadStreamAsync(StreamReader reader)
        {
            IList <ExpandoObject> items = new List <ExpandoObject>();

            string currentLine = await reader.ReadLineAsync();

            int currentLineNumber = 1;

            while (currentLine != null)
            {
                if (!string.IsNullOrWhiteSpace(currentLine))
                {
                    BeforeFluentReadEventArgs beforeReadArgs = OnBeforeReadRecord(currentLine, currentLineNumber);
                    if (!beforeReadArgs.SkipRecord)
                    {
                        if (beforeReadArgs.LineChanged)
                        {
                            currentLine = beforeReadArgs.Line;
                        }

                        ExpandoObject item = await ReadLineAsync(currentLine, Descriptor);

                        AfterFluentReadEventArgs afterReadArgs = OnAfterReadRecord(currentLine, currentLineNumber, item);

                        items.Add(afterReadArgs.Record);
                    }
                }
                currentLineNumber++;
                currentLine = await reader.ReadLineAsync();
            }

            return(items.ToArray());
        }
コード例 #2
0
        protected AfterFluentReadEventArgs OnAfterReadRecord(string line, int lineNumber, ExpandoObject record)
        {
            var args = new AfterFluentReadEventArgs(line, lineNumber)
            {
                Record = record
            };

            AfterReadRecord?.Invoke(this, args);
            args.LineChanged = line != args.Line;
            return(args);
        }