public virtual void CopyME2Properties( ME2Calculator calculator) { //this includes targettype and alterntype this.CopyCalculatorProperties(calculator); this.CopySharedObjectProperties(calculator); this.CopyME2IndicatorsProperties(calculator); }
public virtual void CopyME2CalculatorToME2Stock(ME2Calculator calculator) { //analyzers hold all calcs and analyses if (this.Total1 == null) { this.Total1 = new ME2Total1(this.CalcParameters); } if (this.Stat1 == null) { this.Stat1 = new ME2Stat1(this.CalcParameters); } if (this.Change1 == null) { this.Change1 = new ME2Change1(this.CalcParameters); } if (this.Progress1 == null) { this.Progress1 = new ME2Progress1(this.CalcParameters); } //need to organize stocks by observations this.Stocks = new List <ME2Stock>(); //MEStock uses this.AnalyzerType for most calcs calculator.AnalyzerType = this.AnalyzerType; this.CopyCalculatorProperties(calculator); ME2Stock stock = new ME2Stock(this.CalcParameters); //this copies the ME2Calc.Indicators to the analyzer if (this.AnalyzerType == ME2AnalyzerHelper.ANALYZER_TYPES.mestat1.ToString()) { stock.Stat1 = new ME2Stat1(this.CalcParameters); stock.Stat1.CopyME2Properties(calculator); } else if (this.AnalyzerType == ME2AnalyzerHelper.ANALYZER_TYPES.mechangeyr.ToString() || this.AnalyzerType == ME2AnalyzerHelper.ANALYZER_TYPES.mechangeid.ToString() || this.AnalyzerType == ME2AnalyzerHelper.ANALYZER_TYPES.mechangealt.ToString()) { stock.Change1 = new ME2Change1(this.CalcParameters); stock.Change1.CopyME2Properties(calculator); } else if (this.AnalyzerType == ME2AnalyzerHelper.ANALYZER_TYPES.meprogress1.ToString()) { stock.Progress1 = new ME2Progress1(this.CalcParameters); stock.Progress1.CopyME2Properties(calculator); } else { stock.Total1 = new ME2Total1(this.CalcParameters); stock.Total1.CopyME2Properties(calculator); } this.Stocks.Add(stock); }
private bool RunME2Calculation(ME2CalculatorHelper.CALCULATOR_TYPES calculatorType, ref XElement currentElement, ref XElement currentCalculationsElement) { bool bHasCalculations = false; switch (calculatorType) { case ME2CalculatorHelper.CALCULATOR_TYPES.me2: //serialize, run calcs, and deserialize ME2Calculator me2 = new ME2Calculator(this.GCCalculatorParams); bHasCalculations = me2.SetME2Calculations(calculatorType, this.GCCalculatorParams, ref currentCalculationsElement, ref currentElement); break; default: //should be running an analysis break; } return(bHasCalculations); }
public ME2Stock SetME2Properties(CostBenefitCalculator baseElement, XElement currentCalculationsElement, XElement currentElement) { ME2Stock me2 = new ME2Stock(this.GCCalculatorParams, this.GCCalculatorParams.AnalyzerParms.AnalyzerType); //204 not used //if (this.ME2DescendentStock != null) //{ // //only property set by analyzer // me2.TotalME2Stage = this.ME2DescendentStock.TotalME2Stage; //} ME2Calculator me2Calc = new ME2Calculator(this.GCCalculatorParams); me2.CalcParameters.CurrentElementNodeName = currentElement.Name.LocalName; bool bHasCalcs = false; if (currentCalculationsElement != null) { //have to make sure its not a stockanalyzer string sCalculatorType = CalculatorHelpers.GetAttribute( currentCalculationsElement, Calculator1.cCalculatorType); if (sCalculatorType == ME2CalculatorHelper.CALCULATOR_TYPES.me2.ToString()) { //deserialize xml to object me2Calc.SetME2Properties(currentCalculationsElement, currentElement); //only need alttype and targettype (alts are groupedby using base elements) baseElement.AlternativeType = me2Calc.AlternativeType; baseElement.TargetType = me2Calc.TargetType; bHasCalcs = true; } } if (!bHasCalcs) { //see if a sibling holds the calculations (currentCalcs could be the analyzer) XElement lv = CalculatorHelpers.GetChildLinkedViewUsingAttribute(currentElement, Calculator1.cCalculatorType, ME2CalculatorHelper.CALCULATOR_TYPES.me2.ToString()); if (lv != null) { //deserialize xml to object me2Calc.SetME2Properties(lv, currentElement); //only need alttype and targettype (alts are groupedby using base elements) baseElement.AlternativeType = me2Calc.AlternativeType; baseElement.TargetType = me2Calc.TargetType; bHasCalcs = true; } } if (!bHasCalcs) { //else don't need the ids from calculator me2.CopyCalculatorProperties(baseElement); } //all calcs and analyses are stored in the appropriate analysis object (i.e. me2.Total, me2.Stat) me2.InitTotalME2StocksProperties(); //copy the initial calculator to the appropriate analysis object.ME2Indicators collection me2.CopyME2CalculatorToME2Stock(me2Calc); me2.AnalyzerType = this.GCCalculatorParams.AnalyzerParms.AnalyzerType; //label and date comes from baseelement me2.Label = baseElement.Label; me2.Date = baseElement.Date; //kiss with the multipliers me2.Multiplier = baseElement.Multiplier; me2.CalculatorId = me2Calc.Id; //adjust id if children analyzers are being inserted/updated ChangeCalculatorIdForUpdatedChildren(currentElement, ref currentCalculationsElement, me2); return(me2); }
//copy constructor public ME2Calculator(ME2Calculator me2Calc) : base(me2Calc) { CopyME2Properties(me2Calc); }