Exemple #1
0
        public async ValueTask <bool> MoveNextAsync()
        {
            var result  = false;
            var ptdList = new List <PTurnData>();

            result = await ChunksEnumerator.MoveNextAsync();

            while (result && ptdList.Count < ChunkSize)
            {
                var c    = ChunksEnumerator.Current;
                var cStr = TheLastLine + Encoding.UTF8.GetString(c);
                NewLine = GetEmbeddedNewLineChars(cStr) ?? throw new InvalidOperationException("Invalid format");
                var lines = cStr.Split(NewLine);

                if (CurrentArr == null && (lines.Length == 0 || !ValidateHeader(lines[0])))
                {
                    throw new InvalidOperationException("Invalid format");
                }
                if (lines.Length == 1)
                {
                    result = false; break;
                }

                for (int i = 0; i < lines.Length - 1; i++)
                {
                    if (CurrentArr == null && i == 0)
                    {
                        continue;
                    }

                    ptdList.Add(GetPTurnData(lines[i]));
                }

                result = await ChunksEnumerator.MoveNextAsync();

                if (result)
                {
                    TheLastLine = lines[^ 1];