Reverse() public method

public Reverse ( ) : void
return void
Esempio n. 1
0
        /// <summary>
        /// CSVデータ読み込み
        /// </summary>
        public override void ReadTransactions()
        {
            skipToFirstLine();

            TransactionList transactions = new TransactionList();
            string          line;
            bool            hasFormatError = false;

            while ((line = mSr.ReadLine()) != null)
            {
                // CSV カラム分割
                string[] row = SplitCsv(line);
                if (row.Length <= 1)
                {
                    continue;                  // ad hoc...
                }
                // パース
                try
                {
                    Transaction t = mRule.parse(row);
                    transactions.Add(t);
                }
                catch (FormatException ex)
                {
                    // ignore transaction

                    // MessageBox.Show(ex.Message, Properties.Resources.Error);
                    hasFormatError = true;
                }
            }

            if (transactions.Count == 0 && hasFormatError)
            {
                // フォーマットエラー例外をスロー
                throw new CsvReadException(Properties.Resources.CsvFormatError);
            }

            // ソート処理
            switch (mRule.sortOrder)
            {
            default:
            case CsvRule.SortOrder.Ascent:
                break;

            case CsvRule.SortOrder.Descent:
                transactions.Reverse();
                break;

            case CsvRule.SortOrder.Auto:
                transactions.list.Sort(compareByDate);
                break;
            }

            mTransactions = transactions;
        }
Esempio n. 2
0
        /// <summary>
        /// カード読み込み
        /// Note: 本来はこのメソッドは private で良いが、UnitTest 用に public にしてある。
        /// </summary>
        /// <param name="f"></param>
        /// <returns></returns>
        public TransactionList ReadTransactions(IFelica f)
        {
            TransactionList transactions = new TransactionList();

            f.Polling(mSystemCode);

            if (!analyzeCardId(f))
            {
                throw new Exception(Properties.Resources.CantReadCardNo);
            }

            for (int i = 0; i < mMaxTransactions; i++)
            {
                byte[] data  = new byte[16 * mBlocksPerTransaction];
                byte[] block = null;

                for (int j = 0; j < mBlocksPerTransaction; j++)
                {
                    block = f.ReadWithoutEncryption(mServiceCode, i * mBlocksPerTransaction + j);
                    if (block == null)
                    {
                        break;
                    }

                    block.CopyTo(data, j * 16);
                }
                if (block == null)
                {
                    break;
                }

                Transaction t = new Transaction();

                // データが全0かどうかチェック
                int x = 0;
                foreach (int xx in data)
                {
                    x |= xx;
                }
                if (x == 0)
                {
                    // データが全0なら無視(空エントリ)
                    t.Invalidate();
                }

                // トランザクション解析
                else if (!analyzeTransaction(t, data))
                {
                    t.Invalidate();
                }
                transactions.Add(t);
            }

            if (mNeedReverse)
            {
                transactions.Reverse();
            }
            if (mNeedCalcValue)
            {
                CalcValueFromBalance(transactions);
            }
            PostProcess(transactions);

            return(transactions);
        }
Esempio n. 3
0
        /// <summary>
        /// カード読み込み
        /// Note: 本来はこのメソッドは private で良いが、UnitTest 用に public にしてある。
        /// </summary>
        /// <param name="f"></param>
        /// <returns></returns>
        public TransactionList ReadTransactions(IFelica f)
        {
            TransactionList transactions = new TransactionList();

            f.Polling(mSystemCode);

            if (!analyzeCardId(f)) {
                throw new Exception(Properties.Resources.CantReadCardNo);
            }

            for (int i = 0; i < mMaxTransactions; i++)
            {
                byte[] data = new byte[16 * mBlocksPerTransaction];
                byte[] block = null;

                for (int j = 0; j < mBlocksPerTransaction; j++)
                {
                    block = f.ReadWithoutEncryption(mServiceCode, i * mBlocksPerTransaction + j);
                    if (block == null)
                    {
                        break;
                    }

                    block.CopyTo(data, j * 16);
                }
                if (block == null)
                {
                    break;
                }

                Transaction t = new Transaction();

                // データが全0かどうかチェック
                int x = 0;
                foreach (int xx in data)
                {
                    x |= xx;
                }
                if (x == 0)
                {
                    // データが全0なら無視(空エントリ)
                    t.Invalidate();
                }

                // トランザクション解析
                else if (!analyzeTransaction(t, data))
                {
                    t.Invalidate();
                }
                transactions.Add(t);
            }

            if (mNeedReverse)
            {
                transactions.Reverse();
            }
            if (mNeedCalcValue)
            {
                CalcValueFromBalance(transactions);
            }
            PostProcess(transactions);

            return transactions;
        }
Esempio n. 4
0
        /// <summary>
        /// CSVデータ読み込み
        /// </summary>
        public override void ReadTransactions()
        {
            skipToFirstLine();

            TransactionList transactions = new TransactionList();
            string line;
            bool hasFormatError = false;

            while ((line = mSr.ReadLine()) != null)
            {
                // CSV カラム分割
                string[] row = SplitCsv(line);
                if (row.Length <= 1) continue; // ad hoc...

                // パース
                try
                {
                    Transaction t = mRule.parse(row);
                    transactions.Add(t);
                }
                catch (FormatException ex)
                {
                    // ignore transaction

                    // MessageBox.Show(ex.Message, Properties.Resources.Error);
                    hasFormatError = true;
                }
            }

            if (transactions.Count == 0 && hasFormatError)
            {
                // フォーマットエラー例外をスロー
                throw new CsvReadException(Properties.Resources.CsvFormatError);
            }

            // ソート処理
            switch (mRule.sortOrder)
            {
                default:
                case CsvRule.SortOrder.Ascent:
                    break;

                case CsvRule.SortOrder.Descent:
                    transactions.Reverse();
                    break;

                case CsvRule.SortOrder.Auto:
                    transactions.list.Sort(compareByDate);
                    break;
            }

            mTransactions = transactions;
        }