public void AddValue(IValuation valuation) { Money newValue = ((AvgMarketValue * weight) + (valuation.MarketValue)) / (weight + 1); Money newBaseValue = ((AvgBaseMarketValue * weight) + (valuation.BaseMarketValue)) / (weight + 1); weight++; AvgMarketValue = newValue; AvgBaseMarketValue = newBaseValue; }
public AverageValuation(IValuation valuation, int period) { this.instrument = valuation.Instrument; this.avgMarketValue = valuation.MarketValue; this.avgBaseMarketValue = valuation.BaseMarketValue; this.period = period; weight = 1; }
private void mjButton16_Click(object sender, EventArgs e) { //#region IoC框架功能(一) //IKernel kernel = new StandardKernel(); //kernel.Bind<IValuation>().To<CommoditySumValuation>(); //IValuation valuation = kernel.Get<IValuation>(); //#endregion IKernel kernel = new StandardKernel();//(二) kernel.Bind <IValuation>().To <CommoditySumValuation>(); kernel.Bind <IValuationDisCount>().To <DisCount>(); IValuation valuation = kernel.Get <IValuation>(); ShoppingCart shoppingCart = new ShoppingCart(valuation); MJMessageBox.Show(this, shoppingCart.CommodityTotalPrice().ToString(), "MetroMessagebox", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public ShoppingCart(IValuation valuation) {//1.2 _Valuation = valuation; }