Ejemplo n.º 1
0
        // pseudo computation logic
        private void Compute()
        {
            if (!this.HasAllRequestedInputsForComputation())
            {
                return;
            }

            this.price = PastaCalculator.Compute(this.flourPrice.Value, this.eggPrice.Value, this.flavorPrice.Value, this.sizePrice, this.packagingPrice);

            this.RaisePastaPriceChanged(this.price);
        }
Ejemplo n.º 2
0
        private void Compute()
        {
            if (!this.HasAllRequestedInputsForComputation())
            {
                return;
            }
            // ReSharper disable once PossibleInvalidOperationException
            this.price = PastaCalculator.Compute(this.flourPrice.Value, this.eggPrice.Value, this.flavorPrice.Value, this.sizePrice, this.packagingPrice);

            this.RaisePastaPriceChanged(this.price);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// The subscribe to market data.
 /// </summary>
 /// <param name="marketDatas">
 /// The market data to subscribe to.
 /// </param>
 public void SubscribeToMarketData(IEnumerable<IRawMaterialMarketData> marketDatas)
 {
     this.pastaCalculator = new PastaCalculator();
     this.marketDatas = marketDatas;
     
     // ingredient prices are set at 0
     this.eggPrice = 0;
     this.flourPrice = 0;
     this.flavorPrice = 0;
     foreach (var rawMaterialMarketData in this.marketDatas)
     {
         // indentify the argument family, subscribe to it
         // and invalidate the current value.
         var role = PastaCalculator.ParseRawMaterialRole(rawMaterialMarketData.RawMaterialName);
         switch (role)
         {
             case RawMaterialRole.Flour:
                 this.flourPrice = null;
                 rawMaterialMarketData.PriceChanged += this.MarketData_FlourPriceChanged;
                 break;
             case RawMaterialRole.Egg:
                 this.eggPrice = null;
                 rawMaterialMarketData.PriceChanged += this.MarketData_EggPriceChanged;
                 break;
             case RawMaterialRole.Flavor:
                 this.flavorPrice = null;
                 rawMaterialMarketData.PriceChanged += this.MarketData_FlavorPriceChanged;
                 break;
         }
     }
 }