AGRアカウント
Inheritance: Account
Exemplo n.º 1
0
            private AgrAccount newAccount(string line, bool isCreditCard)
            {
                AgrAccount account = new AgrAccount();

                account.isCreditCard = isCreditCard;
                if (!account.readAccountInfo(line, mNameHash))
                {
                    return(null);
                }
                return(account);
            }
Exemplo n.º 2
0
 private AgrAccount newAccount(string line, bool isCreditCard)
 {
     AgrAccount account = new AgrAccount();
     account.isCreditCard = isCreditCard;
     if (!account.readAccountInfo(line, mNameHash))
     {
         return null;
     }
     return account;
 }
Exemplo n.º 3
0
        public bool load(StreamReader sr)
        {
            try
            {
                // フォーマットチェック
                string line = sr.ReadLine();
                if (line != "\"あぐりっぱ\",\"1.0\"")
                {
                    return(false);
                }

                mAccounts = new List <Account>();
                AgrAccount account = null;

                AgrAccount.Builder builder = new AgrAccount.Builder();

                // 行をパースする
                State state        = State.SearchingStart;
                bool  isCreditCard = false;

                while ((line = sr.ReadLine()) != null)
                {
                    switch (state)
                    {
                    case State.SearchingStart:
                        if (line.StartsWith("<START_CP"))
                        {
                            if (line.EndsWith("_PAY>"))
                            {
                                state        = State.ReadAccountInfo;
                                isCreditCard = true;
                            }
                            else if (line.EndsWith("_ORD>"))
                            {
                                state        = State.ReadAccountInfo;
                                isCreditCard = false;
                            }
                            else
                            {
                                // ignore : _BILL など
                            }
                        }
                        break;

                    case State.ReadAccountInfo:
                        if (line.StartsWith("<END_"))
                        {
                            // no definition line : ignore
                            state = State.SearchingStart;
                            break;
                        }
                        if (isCreditCard)
                        {
                            account = builder.newCreditCardAccount(line);
                        }
                        else
                        {
                            account = builder.newBankAccount(line);
                        }
                        if (account == null)
                        {
                            sr.Close();
                            return(false);
                        }
                        state = State.ReadTransactions;
                        break;

                    case State.ReadTransactions:
                        if (line.StartsWith("<END_"))
                        {
                            mAccounts.Add(account);
                            state = State.SearchingStart;
                        }
                        else
                        {
                            if (!account.readTransaction(line))
                            {
                                // 解析エラー: この取引は無視する
                            }
                        }
                        break;
                    }
                }
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }
            }
            return(true);
        }