public List <POLine_v2> Parse(string[] lines)
        {
            List <POLine_v2> transactionLines = new List <POLine_v2>(1000);

            POLine_v2 poLine = new POLine_v2();

            State state = State.ID;

            foreach (var line in lines)
            {
                if (string.IsNullOrEmpty(line))
                {
                    if (state >= State.Note)
                    {
                        transactionLines.Add(poLine);
                        state = State.ID;
                    }

                    continue;
                }
                switch (state)
                {
                case State.ID:
                {
                    poLine.ID = int.Parse(line);

                    state++;
                    break;
                }

                case State.DateTime:
                {
                    var dt = line.Split('T');
                    poLine.PODateTime.Date = dt[0];
                    poLine.PODateTime.Time = dt[1];

                    state++;
                    break;
                }

                case State.Amount:
                {
                    poLine.Amount = double.Parse(line);

                    state++;
                    break;
                }

                case State.Note:
                {
                    poLine.Note += line;

                    state++;
                    break;
                }
                }
            }

            return(transactionLines);
        }
Beispiel #2
0
        public POLine_v2[] Parse(string[] lines, out int index)
        {
            index = 0;

            POLine_v2[] transactionLines = new POLine_v2[1000];
            POLine_v2   poLine           = new POLine_v2();

            State state = State.ID;

            foreach (var line in lines)
            {
                if (string.IsNullOrEmpty(line))
                {
                    if (state >= State.Note)
                    {
                        transactionLines[index] = poLine;
                        state = State.ID;
                        index++;
                    }

                    continue;
                }
                switch (state)
                {
                case State.ID:
                {
                    poLine.ID = int.Parse(line);

                    state++;
                    break;
                }

                case State.DateTime:
                {
                    var dt = line.Split('T');
                    poLine.PODateTime.Date = dt[0];
                    poLine.PODateTime.Time = dt[1];

                    state++;
                    break;
                }

                case State.Amount:
                {
                    poLine.Amount = double.Parse(line);

                    state++;
                    break;
                }

                case State.Note:
                {
                    poLine.Note += line;

                    state++;
                    break;
                }
                }
            }

            return(transactionLines);
        }