Exemple #1
0
        public bool MoveNext()
        {
            var result = true;

            if (LinesList.Count > 0)
            {
                Current = LinesList[0];
                LinesList.RemoveAt(0);
            }
            else
            {
                int i;
                for (i = 0; i < MaxRetryCount; i++)
                {
                    result = ChunksEnumerator.MoveNext();
                    if (result)
                    {
                        var c   = ChunksEnumerator.Current;
                        var str = LastStr + Encoding.UTF8.GetString(c);
                        if (string.IsNullOrEmpty(NewLine))
                        {
                            NewLine = GetEmbeddedNewLineChars(str);
                        }
                        var lines = (string.IsNullOrEmpty(NewLine)) ? new string[0] : str.Split(NewLine);

                        if (Current == null && lines.Length > 0)
                        {
                            if (!ValidateHeader(lines[0]))
                            {
                                throw new InvalidOperationException();
                            }
                        }

                        if (Current == null && lines.Length == 2)
                        {
                            LastStr = lines[1];
                            continue;
                        }
                        else if (Current == null && lines.Length > 2)
                        {
                            for (int t = 1; t < lines.Length - 1; t++)
                            {
                                LinesList.Add(GetPTurnData(lines[t]));
                            }
                            Current = LinesList[0];
                            LinesList.RemoveAt(0);
                            LastStr = lines[^ 1];
Exemple #2
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];
Exemple #3
0
 public void Dispose()
 {
     ChunksEnumerator.Dispose();
 }
Exemple #4
0
 public async ValueTask DisposeAsync()
 {
     await ChunksEnumerator.DisposeAsync();
 }