/// <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); }
/// <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; }