Develop and Download Open Source Software

Browse Subversion Repository

Contents of /tags/FeliCa2Money-2.2/Card.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 109 - (show annotations) (download)
Sun Mar 9 06:14:50 2008 UTC (16 years, 1 month ago) by tmurakam
File size: 3097 byte(s)
ver 2.2

1 /*
2 * FeliCa2Money
3 *
4 * Copyright (C) 2001-2008 Takuya Murakami
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21 using System;
22 using System.Collections.Generic;
23 using System.Text;
24 using FelicaLib;
25
26 namespace FeliCa2Money
27 {
28 abstract class Card
29 {
30 protected string ident;
31 protected string cardName;
32 protected string cardId;
33
34 public abstract List<Transaction> ReadCard();
35
36 public string Ident
37 {
38 get { return this.ident; }
39 }
40
41 public string CardName
42 {
43 get { return this.cardName; }
44 }
45
46 public string CardId
47 {
48 set { this.cardId = value; }
49 get { return this.cardId; }
50 }
51
52 protected string[] ParseLine(string line)
53 {
54 return line.Split('\t');
55 }
56 }
57
58 abstract class CardWithFelicaLib : Card, IDisposable
59 {
60 protected int systemCode; // ���������������������
61 protected int serviceCode; // ���������������������
62 protected bool needReverse; // ���������������������������������������������
63
64 // ��������� ID ������
65 public abstract void analyzeCardId(Felica f);
66
67 // Transaction ������
68 public abstract bool analyzeTransaction(Transaction t, byte[] data);
69
70 public override List<Transaction> ReadCard()
71 {
72 List<Transaction> list = new List<Transaction>();
73
74 using (Felica f = new Felica())
75 {
76 f.Polling(systemCode);
77 analyzeCardId(f);
78
79 for (int i = 0; ; i++)
80 {
81 byte[] data = f.ReadWithoutEncryption(serviceCode, i);
82 if (data == null) break;
83
84 Transaction t = new Transaction();
85 if (analyzeTransaction(t, data))
86 {
87 list.Add(t);
88 }
89 }
90 }
91 if (needReverse)
92 {
93 list.Reverse();
94 }
95 PostProcess(list);
96
97 return list;
98 }
99
100 protected virtual void PostProcess(List<Transaction> list)
101 {
102 // do nothing
103 }
104
105 public virtual void Dispose()
106 {
107 }
108 }
109 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26