//define the actions to take when the event is raised public void AddCalculations(object sender, CustomEventArgs e) { //pass a byref xelement from the publisher's data XElement statElement = null; XElement linkedViewElement = null; if (e.CurrentElement != null) { statElement = new XElement(e.CurrentElement); } if (e.LinkedViewElement != null) { linkedViewElement = new XElement(e.LinkedViewElement); } NPV1CalculatorHelper.CALCULATOR_TYPES eCalculatorType = NPV1CalculatorHelper.GetCalculatorType( this.GCCalculatorParams.CalculatorType); //run the stats and add them to statelement //run normally and save the same statelement and linkedviewelement e.HasCalculations = RunNPV1Analysis( ref statElement, ref linkedViewElement); if (e.HasCalculations) { //pass the new statelement back to the publisher //by setting the CalculatedElement property of CustomEventArgs if (statElement != null) { e.CurrentElement = new XElement(statElement); } if (linkedViewElement != null) { e.LinkedViewElement = new XElement(linkedViewElement); } } }
private bool RunNPV1Calculation(NPV1CalculatorHelper.CALCULATOR_TYPES calculatorType, ref XElement currentElement, ref XElement currentCalculationsElement) { bool bHasCalculations = false; switch (calculatorType) { //case NPV1CalculatorHelper.CALCULATOR_TYPES.buildcost1: // //serialize, run calcs, and deserialize // //NPVC1Calculator lcc1 = new NPVC1Calculator(); // //bHasCalculations = lcc1.SetNPVC1Calculations(calculatorType, this.GCCalculatorParams, // // ref currentCalculationsElement, ref currentElement); // break; //case NPV1CalculatorHelper.CALCULATOR_TYPES.buildbenefit1: // ////serialize, run calcs, and deserialize // //NPVB1Calculator lcb1 = new NPVB1Calculator(); // //bHasCalculations = lcb1.SetNPVB1Calculations(calculatorType, this.GCCalculatorParams, // // ref currentCalculationsElement, ref currentElement); // break; default: //should be running an analysis break; } return(bHasCalculations); }
private static void CheckForLastStepCalculator( CalculatorParameters npv1CalcParams, ContractHelpers.EXTENSION_STEPS stepNumber, ExtensionContentURI extDocToCalcURI) { NPV1CalculatorHelper.CALCULATOR_TYPES eCalculatorType = NPV1CalculatorHelper.GetCalculatorType( npv1CalcParams.CalculatorType); //other projects have code for handling different //numbers of steps in calculators }