コード例 #1
0
        /// <summary>
        /// load cash for work
        /// </summary>
        /// <param name="filePath">cash log file</param>
        private void LoadCash(string filePath)
        {
            if (File.Exists(filePath))
            {
                BinaryReader reader = new BinaryReader(File.Open(filePath, FileMode.Open));

                try
                {
                    while (reader.BaseStream.Length != reader.BaseStream.Position)
                    {
                        int   key  = reader.ReadInt32();
                        ICash cash = (ICash)Activator.CreateInstance(
                            Type.GetType(reader.ReadString()));
                        cash.Amount = reader.ReadDouble();

                        this.cash.Add((Currency)key, cash);
                    }
                }
                catch (Exception e)
                {
                    throw new ArgumentException(e.Message);
                }
                finally
                {
                    reader.Close();
                }
            }
            else
            {
                throw new ArgumentNullException("file does not exists");
            }
        }
コード例 #2
0
        public void Remove(ICash denomination, int amount)
        {
            bool exists = CashStack.TryGetValue(denomination, out int value);

            if (exists)
            {
                CashStack[denomination] = value - amount;
            }
        }
コード例 #3
0
ファイル: Index.cshtml.cs プロジェクト: mojosaleem/Systems
 public IndexModel(ICar car, ICapitalShare capitalShare, IAfterSellExpncess afterSellExpncess, ICheck check, ICash cash)
 {
     this.car = car;
     this.afterSellExpncess = afterSellExpncess;
     this.capitalShare      = capitalShare;
     this.check             = check;
     this.cash = cash;
     model     = new outputModel();
 }
コード例 #4
0
ファイル: mantain.cshtml.cs プロジェクト: mojosaleem/Systems
 public mantainModel(IBuyRecords buyRecords, IOutcome outcome, ICash cash, IIncome income, ISellrecord sellrecord, IAfterBuyExpncess afterBuyExpncess, IAfterSellExpncess afterSellExpncess)
 {
     this.buyRecords        = buyRecords;
     this.sellrecord        = sellrecord;
     this.afterBuyExpncess  = afterBuyExpncess;
     this.afterSellExpncess = afterSellExpncess;
     this.income            = income;
     this.cash    = cash;
     this.outcome = outcome;
 }
コード例 #5
0
        /// <summary>
        /// Add cash to account
        /// </summary>
        /// <param name="id">Account ud</param>
        /// <param name="currency">New cash currency</param>
        /// <param name="cash">Cash type</param>
        public void AddCash(string id, Currency currency, ICash cash)
        {
            Account tmp = _storage.GetAccountById(id);

            if (tmp.AddCash(currency, cash))
            {
                _storage.UpdateAccount(tmp);

                Notify(tmp, string.Format("You have successfully added new {0} cash", currency));
            }
        }
コード例 #6
0
 /// <summary>
 /// add new cash
 /// </summary>
 /// <param name="key">enumerable cash representation</param>
 /// <param name="cash">cash kind</param>
 public void AddCash(Currency key, ICash cash)
 {
     if (!this.cash.ContainsKey(key))
     {
         this.cash[key] = cash;
     }
     else
     {
         throw new ArgumentException(string.Format("cash {0} already exists", key));
     }
 }
コード例 #7
0
ファイル: CreditCard.cs プロジェクト: KimKiHyuk/DesignPattern
 public CreditCard(Type cash)
 {
     if (cash == typeof(KakaoAccount))
     {
         this.cash = new KakaoAccount();
     }
     else if (cash == typeof(UriAccount))
     {
         this.cash = new UriAccount();
     }
 }
コード例 #8
0
ファイル: Sale.cshtml.cs プロジェクト: mojosaleem/Systems
 public SaleModel(ICar car, IManufacture manufacture, Ifile file, ISale sale, ISellrecord sellrecord, IIncome income, ICash cash, ICheck check, ICustomer customer)
 {
     this.car         = car;
     this.manufacture = manufacture;
     _file            = file;
     _sale            = sale;
     this.sellrecord  = sellrecord;
     this.income      = income;
     this.cash        = cash;
     this.check       = check;
     this.customer    = customer;
 }
コード例 #9
0
        /// <summary>
        /// Adds the given amount to this entry.
        /// If no matching entry exists, one will be created
        /// </summary>
        /// <param name="denomination">The denomination to adjust</param>
        /// <param name="amount">The amount of this denomination to add (use negative values to subtract)</param>
        public void Edit(ICash denomination, int amount)
        {
            bool exists = CashStack.TryGetValue(denomination, out int value);

            if (exists)
            {
                CashStack[denomination] = value + amount;
            }
            else
            {
                CashStack.Add(denomination, amount);
            }
        }
コード例 #10
0
        public void CanMakeSingleTypeLimitedCashSet(decimal value)
        {
            CashSet cashSet = (CashSet)CashController.SmallestSetForValue(value, Mocks.MockCashSets.StandardSet);

            ICash item = (from cashItem
                          in cashSet.CashStack
                          where cashItem.Key.UnitValue == value
                          select cashItem.Key).FirstOrDefault();

            cashSet.CashStack.TryGetValue(item, out int amount);

            Assert.AreEqual(1, amount);
        }
コード例 #11
0
 /// <summary>
 /// change existing cash
 /// </summary>
 /// <param name="key">enumerable cash representation</param>
 /// <param name="cash">cash kind</param>
 public void ChangeCash(Currency key, ICash cash)
 {
     if (this.cash.ContainsKey(key))
     {
         double tempAmount = this.cash[key].Amount;
         this.cash[key] = cash;
         Replenish(key, tempAmount);
     }
     else
     {
         throw new ArgumentNullException(string.Format("cash {0} does not exists", key));
     }
 }
コード例 #12
0
        /// <summary>
        /// 簡單工廠pattern
        /// </summary>
        /// <returns></returns>
        public static ICash CreateCashFactory(CashType cashType)
        {
            ICash instance = cashType switch
            {
                CashType.Normal => new CashNormal(),
                CashType.Rebate => new CashRebate(0.8),
                CashType.Return => new CashReturn(300, 100),
                _ => throw new Exception("不知名外星人")
            };

            return(instance);
        }
    }
コード例 #13
0
 public buyAcarModel(IHostingEnvironment hostingEnv, ICheck incomes, IManufacture manufacture, IOutcome outcome, ICar car, IBuy buy, ICash cash, ICheck check, IBuyRecords buyrecord, Iperson saleperson, Ifile file)
 {
     _incomes     = incomes;
     _hostingEnv  = hostingEnv;
     _manufacture = manufacture;
     _outcome     = outcome;
     _car         = car;
     _buy         = buy;
     _cash        = cash;
     _check       = check;
     _buyrecord   = buyrecord;
     _saleperson  = saleperson;
     _file        = file;
 }
コード例 #14
0
ファイル: CashBag.cs プロジェクト: kgzpsb/ZPSB202009
        private void AppendMoney(Cash aMoney)
        {
            ICash old = FindMoney(aMoney.Currency);

            if (old == null)
            {
                fMonies.Add(aMoney);
                return;
            }
            fMonies.Remove(old);
            ICash sum = old.Add(aMoney);

            if (sum.IsZero)
            {
                return;
            }
            fMonies.Add(sum);
        }
コード例 #15
0
 /// <summary>
 /// Adds a new denomination of money to this drawer
 /// </summary>
 /// <param name="denomination">The type of cash to add</param>
 /// <param name="amount">(optional) The initial amount of this item to add (default: 0)</param>
 public void Add(ICash denomination, int amount = 0)
 {
     Edit(denomination, amount);
 }
コード例 #16
0
ファイル: CashBag.cs プロジェクト: kgzpsb/ZPSB202009
 public ICash AddMoneyBag(ICash s)
 {
     return((new CashBag((Cash)s, this)).Simplify());
 }
コード例 #17
0
ファイル: CashBag.cs プロジェクト: kgzpsb/ZPSB202009
 public ICash Add(ICash m)
 {
     return(m.AddMoneyBag(this));
 }
コード例 #18
0
 /// <summary>
 /// Add cash to account
 /// </summary>
 /// <param name="id">Account ud</param>
 /// <param name="currency">New cash currency</param>
 /// <param name="cash">Cash type</param>
 public void AddCash(string id, Currency currency, ICash cash)
 {
     _storage.GetAccountById(id).AddCash(currency, cash);
 }
コード例 #19
0
 public void ChangeContent(ICash cashItem, int difference)
 {
     DrawerContent.Edit(cashItem, difference);
 }
コード例 #20
0
ファイル: CashBag.cs プロジェクト: kgzpsb/ZPSB202009
 public ICash Subtract(ICash m)
 {
     return(Add(m.Negate()));
 }
コード例 #21
0
 public ValuesController(ICash car)
 {
     this.Cash = car;
 }
コード例 #22
0
ファイル: Cash.cs プロジェクト: kgzpsb/ZPSB202009
 public ICash AddMoneyBag(ICash s)
 {
     return(s.AddMoney(this));
 }