private IEnumerable <XElement> StreamTimePeriods() { //loop through the descendants in document order while (this.GCCalculatorParams.DocToCalcReader.Read()) { if (this.GCCalculatorParams.DocToCalcReader.NodeType == XmlNodeType.Element) { if (this.GCCalculatorParams.DocToCalcReader.Name == Constants.ROOT_PATH) { //skip using while } else if (this.GCCalculatorParams.DocToCalcReader.Name == BudgetInvestment.BUDGET_TYPES.budgettimeperiod.ToString() || this.GCCalculatorParams.DocToCalcReader.Name == BudgetInvestment.INVESTMENT_TYPES.investmenttimeperiod.ToString()) { //read currentElement including xmldocnodes XElement currentElement = CalculatorHelpers.GetCurrentElementWithAttributes( this.GCCalculatorParams.DocToCalcReader); //don't process previously calculated nodes bool bIsAnnuity = TimePeriod.IsAnnuity(currentElement); if (!bIsAnnuity) { //attach linked views separately (put in first position) CalculatorHelpers.AddLinkedViewsToCurrentElementWithReader(this.GCCalculatorParams.ExtensionDocToCalcURI, this.GCCalculatorParams.AnalyzerParms.ObservationsPath, ref currentElement); //OnSetAncestorObjects(GCArguments); //use streaming techniques to process descendants IEnumerable <XElement> childElements = from childElement in StreamTimePeriodChildren() select childElement; if (currentElement != null) { if (childElements != null) { //add the child elements to the currentElement currentElement.Add(childElements); } Task <bool> hascalc = this.RunCalculationsAndSetUpdatesAsync(currentElement); yield return(currentElement); } } } } else if (this.GCCalculatorParams.DocToCalcReader.NodeType == XmlNodeType.EndElement) { if (this.GCCalculatorParams.DocToCalcReader.Name == BudgetInvestment.BUDGET_TYPES.budget.ToString() || this.GCCalculatorParams.DocToCalcReader.Name == BudgetInvestment.INVESTMENT_TYPES.investment.ToString()) { break; } } } }
private IEnumerable <XElement> StreamOutcome() { //loop through the descendants in document order while (this.GCCalculatorParams.DocToCalcReader.Read()) { if (this.GCCalculatorParams.DocToCalcReader.NodeType == XmlNodeType.Element) { if (this.GCCalculatorParams.DocToCalcReader.Name == Constants.ROOT_PATH) { //skip using while } else if (this.GCCalculatorParams.DocToCalcReader.Name == Outcome.OUTCOME_PRICE_TYPES.outcome.ToString()) { //use streaming techniques to process descendants XElement currentElement = CalculatorHelpers.GetCurrentElementWithAttributes( this.GCCalculatorParams.DocToCalcReader); //attach linked views separately (or the readdescendant syntax skips) CalculatorHelpers.AddLinkedViewsToCurrentElementWithReader( this.GCCalculatorParams.ExtensionDocToCalcURI, this.GCCalculatorParams.AnalyzerParms.ObservationsPath, ref currentElement); //set stateful ancestor objects (i.e. this.GCCalculatorParams.ParentBudget) //that descendants use in their calculations this.GCArguments.CurrentElement = currentElement; OnSetAncestorObjects(this.GCArguments); IEnumerable <XElement> childElements = null; if (this.GCCalculatorParams.DocToCalcReader.Name == Outcome.OUTCOME_PRICE_TYPES.outcome.ToString()) { childElements = from childElement in StreamOutcomeOutput() select childElement; } if (currentElement != null) { if (childElements != null) { //add the child elements to the currentElement currentElement.Add(childElements); } this.RunCalculationsAndSetUpdates(ref currentElement); yield return(currentElement); } } } else if (this.GCCalculatorParams.DocToCalcReader.NodeType == XmlNodeType.EndElement) { if (this.GCCalculatorParams.DocToCalcReader.Name == Outcome.OUTCOME_PRICE_TYPES.outcomegroup.ToString()) { break; } } } }
private IEnumerable <XElement> StreamBudgetInvestments() { //loop through the descendants in document order while (this.GCCalculatorParams.DocToCalcReader.Read()) { if (this.GCCalculatorParams.DocToCalcReader.NodeType == XmlNodeType.Element) { if (this.GCCalculatorParams.DocToCalcReader.Name == Constants.ROOT_PATH) { //skip using while } else if (this.GCCalculatorParams.DocToCalcReader.Name == BudgetInvestment.BUDGET_TYPES.budget.ToString() || this.GCCalculatorParams.DocToCalcReader.Name == BudgetInvestment.INVESTMENT_TYPES.investment.ToString()) { //use streaming techniques to process descendants XElement currentElement = CalculatorHelpers.GetCurrentElementWithAttributes( this.GCCalculatorParams.DocToCalcReader); //attach linked views separately (or the ancestor.linkedview can't be set) CalculatorHelpers.AddLinkedViewsToCurrentElementWithReader( this.GCCalculatorParams.ExtensionDocToCalcURI, this.GCCalculatorParams.AnalyzerParms.ObservationsPath, ref currentElement); //set stateful ancestor objects (i.e. this.GCCalculatorParams.ParentBudget) //that descendants use in their calculations GCArguments.CurrentElement = currentElement; OnSetAncestorObjects(GCArguments); IEnumerable <XElement> childElements = from childElement in StreamTimePeriods() select childElement; if (currentElement != null) { if (childElements != null) { //add the child elements to the currentElement currentElement.Add(childElements); } this.RunCalculationsAndSetUpdates(ref currentElement); yield return(currentElement); } } } else if (this.GCCalculatorParams.DocToCalcReader.NodeType == XmlNodeType.EndElement) { if (this.GCCalculatorParams.DocToCalcReader.Name == BudgetInvestment.BUDGET_TYPES.budgetgroup.ToString() || this.GCCalculatorParams.DocToCalcReader.Name == BudgetInvestment.INVESTMENT_TYPES.investmentgroup.ToString()) { break; } } } }
protected virtual IEnumerable <XElement> StreamOperationComponentGroups() { //loop through the descendants in document order while (this.GCCalculatorParams.DocToCalcReader.Read()) { if (this.GCCalculatorParams.DocToCalcReader.NodeType == XmlNodeType.Element) { if (this.GCCalculatorParams.DocToCalcReader.Name == OperationComponent.OPERATION_PRICE_TYPES.operationgroup.ToString() || this.GCCalculatorParams.DocToCalcReader.Name == OperationComponent.COMPONENT_PRICE_TYPES.componentgroup.ToString()) { this.GCCalculatorParams.ChangeStartingParams( this.GCCalculatorParams.DocToCalcReader.Name); //use streaming techniques to process descendants XElement currentElement = CalculatorHelpers.GetCurrentElementWithAttributes( this.GCCalculatorParams.DocToCalcReader); //attach linked views separately (or the ancestor.linkedview can't be set) CalculatorHelpers.AddLinkedViewsToCurrentElementWithReader( this.GCCalculatorParams.ExtensionDocToCalcURI, this.GCCalculatorParams.AnalyzerParms.ObservationsPath, ref currentElement); //set stateful ancestor objects (i.e. this.GCCalculatorParams.ParentBudget) //that descendants use in their calculations this.GCArguments.CurrentElement = currentElement; OnSetAncestorObjects(this.GCArguments); IEnumerable <XElement> childElements = from childElement in StreamOperationComponent() select childElement; if (currentElement != null) { if (childElements != null) { //add the child elements to the currentElement currentElement.Add(childElements); } this.RunCalculationsAndSetUpdates(ref currentElement); yield return(currentElement); } } } else if (this.GCCalculatorParams.DocToCalcReader.NodeType == XmlNodeType.EndElement) { if (this.GCCalculatorParams.DocToCalcReader.Name == Constants.ROOT_PATH) { break; } } } }
protected virtual IEnumerable <XElement> StreamInputOrOutputGroups() { //loop through the descendants in document order while (this.GCCalculatorParams.DocToCalcReader.Read()) { if (this.GCCalculatorParams.DocToCalcReader.NodeType == XmlNodeType.Element) { if (this.GCCalculatorParams.DocToCalcReader.Name == Input.INPUT_PRICE_TYPES.inputgroup.ToString() || this.GCCalculatorParams.DocToCalcReader.Name == Output.OUTPUT_PRICE_TYPES.outputgroup.ToString()) { this.GCCalculatorParams.ChangeStartingParams( this.GCCalculatorParams.DocToCalcReader.Name); //use streaming techniques to process descendants XElement currentElement = CalculatorHelpers.GetCurrentElementWithAttributes( this.GCCalculatorParams.DocToCalcReader); //attach linked views separately (or the ancestor.linkedview can't be set) CalculatorHelpers.AddLinkedViewsToCurrentElementWithReader(this.GCCalculatorParams.ExtensionDocToCalcURI, this.GCCalculatorParams.AnalyzerParms.ObservationsPath, ref currentElement); //SetAncestorObjects(currentElement); IEnumerable <XElement> childElements = from childElement in StreamInputOrOutputs() select childElement; if (currentElement != null) { if (childElements != null) { //add the child elements to the currentElement currentElement.Add(childElements); } Task <bool> hascalc = this.RunCalculationsAndSetUpdatesAsync(currentElement); //_lvTasks.Add(this.RunCalculationsAndSetUpdatesAsync(currentElement)); yield return(currentElement); } } } else if (this.GCCalculatorParams.DocToCalcReader.NodeType == XmlNodeType.EndElement) { if (this.GCCalculatorParams.DocToCalcReader.Name == Constants.ROOT_PATH) { break; } } } }
private IEnumerable <XElement> StreamInvestmentOutcome() { //not all calculations include outcomes, so use ReadToDescendent syntax //this works even without outcomes as long as the parent "outcomes" node //is yielded, and that node has no xmldoc calcs while (this.GCCalculatorParams.DocToCalcReader.ReadToDescendant( BudgetInvestment.INVESTMENT_TYPES.investmentoutcome.ToString())) { if (this.GCCalculatorParams.DocToCalcReader.NodeType == XmlNodeType.Element) { //use streaming techniques to process descendants XElement currentElement = CalculatorHelpers.GetCurrentElementWithAttributes( this.GCCalculatorParams.DocToCalcReader); //attach linked views separately (or the readdescendant syntax skips) CalculatorHelpers.AddLinkedViewsToCurrentElementWithReader( this.GCCalculatorParams.ExtensionDocToCalcURI, this.GCCalculatorParams.AnalyzerParms.ObservationsPath, ref currentElement); //don't process previously calculated nodes bool bIsAnnuity = TimePeriod.IsAnnuity(currentElement); if (!bIsAnnuity) { //set stateful ancestor objects (i.e. this.GCCalculatorParams.ParentOutcome) //that descendants use in their calculations GCArguments.CurrentElement = currentElement; OnSetAncestorObjects(GCArguments); IEnumerable <XElement> childElements = null; childElements = from childElement in StreamInvestmentOutput() select childElement; if (currentElement != null) { if (childElements != null) { currentElement.Add(childElements); } this.RunCalculationsAndSetUpdates(ref currentElement); yield return(currentElement); } } //process sibling outcomes while (this.GCCalculatorParams.DocToCalcReader .ReadToNextSibling(BudgetInvestment.INVESTMENT_TYPES.investmentoutcome.ToString())) { if (this.GCCalculatorParams.DocToCalcReader.NodeType == XmlNodeType.Element) { XElement siblingElement = CalculatorHelpers.GetCurrentElementWithAttributes( this.GCCalculatorParams.DocToCalcReader); //attach linked views separately (or the readdescendant syntax skips) CalculatorHelpers.AddLinkedViewsToCurrentElementWithReader( this.GCCalculatorParams.ExtensionDocToCalcURI, this.GCCalculatorParams.AnalyzerParms.ObservationsPath, ref siblingElement); //don't process previously calculated nodes bIsAnnuity = TimePeriod.IsAnnuity(siblingElement); if (!bIsAnnuity) { //set stateful ancestor objects (i.e. this.GCCalculatorParams.ParentOutcome) //that descendants use in their calculations GCArguments.CurrentElement = siblingElement; OnSetAncestorObjects(GCArguments); IEnumerable <XElement> childElements = null; childElements = from childElement in StreamInvestmentOutput() select childElement; if (siblingElement != null) { if (childElements != null) { siblingElement.Add(childElements); } this.RunCalculationsAndSetUpdates(ref siblingElement); yield return(siblingElement); } } } else if (this.GCCalculatorParams.DocToCalcReader.NodeType == XmlNodeType.EndElement) { if (this.GCCalculatorParams.DocToCalcReader.Name == BudgetInvestment.BUDGET_TYPES.budgetoutcomes.ToString() || this.GCCalculatorParams.DocToCalcReader.Name == BudgetInvestment.INVESTMENT_TYPES.investmentoutcomes.ToString()) { break; } } } } else if (this.GCCalculatorParams.DocToCalcReader.NodeType == XmlNodeType.EndElement) { if (this.GCCalculatorParams.DocToCalcReader.Name == BudgetInvestment.BUDGET_TYPES.budgetoutcomes.ToString() || this.GCCalculatorParams.DocToCalcReader.Name == BudgetInvestment.INVESTMENT_TYPES.investmentoutcomes.ToString()) { break; } } } }
private IEnumerable <XElement> StreamOperationComponent() { //loop through the descendants in document order while (this.GCCalculatorParams.DocToCalcReader.Read()) { if (this.GCCalculatorParams.DocToCalcReader.NodeType == XmlNodeType.Element) { if (this.GCCalculatorParams.DocToCalcReader.Name == BudgetInvestment.BUDGET_TYPES.budgetoperation.ToString() || this.GCCalculatorParams.DocToCalcReader.Name == BudgetInvestment.INVESTMENT_TYPES.investmentcomponent.ToString()) { //use streaming techniques to process descendants XElement currentElement = CalculatorHelpers.GetCurrentElementWithAttributes( this.GCCalculatorParams.DocToCalcReader); //attach linked views separately (or the readdescendant syntax skips) CalculatorHelpers.AddLinkedViewsToCurrentElementWithReader( this.GCCalculatorParams.ExtensionDocToCalcURI, this.GCCalculatorParams.AnalyzerParms.ObservationsPath, ref currentElement); //don't process previously calculated nodes bool bIsAnnuity = TimePeriod.IsAnnuity(currentElement); if (!bIsAnnuity) { //set stateful ancestor objects (i.e. this.GCCalculatorParams.ParentBudget) //that descendants use in their calculations GCArguments.CurrentElement = currentElement; OnSetAncestorObjects(GCArguments); IEnumerable <XElement> childElements = null; if (this.GCCalculatorParams.DocToCalcReader.Name == BudgetInvestment.BUDGET_TYPES.budgetoperation.ToString()) { childElements = from childElement in StreamBudgetInput() select childElement; } else if (this.GCCalculatorParams.DocToCalcReader.Name == BudgetInvestment.INVESTMENT_TYPES.investmentcomponent.ToString()) { childElements = from childElement in StreamInvestmentInput() select childElement; } if (currentElement != null) { if (childElements != null) { currentElement.Add(childElements); } this.RunCalculationsAndSetUpdates(ref currentElement); yield return(currentElement); } } } } else if (this.GCCalculatorParams.DocToCalcReader.NodeType == XmlNodeType.EndElement) { if (this.GCCalculatorParams.DocToCalcReader.Name == BudgetInvestment.BUDGET_TYPES.budgetoperations.ToString() || this.GCCalculatorParams.DocToCalcReader.Name == BudgetInvestment.INVESTMENT_TYPES.investmentcomponents.ToString()) { break; } } } }
private IEnumerable <XElement> StreamOperationComponents() { //loop through the descendants in document order while (this.GCCalculatorParams.DocToCalcReader.Read()) { if (this.GCCalculatorParams.DocToCalcReader.NodeType == XmlNodeType.Element) { if (this.GCCalculatorParams.DocToCalcReader.Name == Constants.ROOT_PATH) { //skip using while } else if (this.GCCalculatorParams.DocToCalcReader.Name == OperationComponent.OPERATION_PRICE_TYPES.operation.ToString() || this.GCCalculatorParams.DocToCalcReader.Name == OperationComponent.COMPONENT_PRICE_TYPES.component.ToString()) { //use streaming techniques to process descendants XElement currentElement = CalculatorHelpers.GetCurrentElementWithAttributes( this.GCCalculatorParams.DocToCalcReader); //attach linked views separately (or the readdescendant syntax skips) CalculatorHelpers.AddLinkedViewsToCurrentElementWithReader(this.GCCalculatorParams.ExtensionDocToCalcURI, this.GCCalculatorParams.AnalyzerParms.ObservationsPath, ref currentElement); //OnSetAncestorObjects(this.GCArguments); IEnumerable <XElement> childElements = null; if (this.GCCalculatorParams.DocToCalcReader.Name == OperationComponent.OPERATION_PRICE_TYPES.operation.ToString()) { childElements = from childElement in StreamOperationInputs() select childElement; } else if (this.GCCalculatorParams.DocToCalcReader.Name == OperationComponent.COMPONENT_PRICE_TYPES.component.ToString()) { childElements = from childElement in StreamComponentInputs() select childElement; } if (currentElement != null) { if (childElements != null) { //add the child elements to the currentElement currentElement.Add(childElements); } Task <bool> hascalc = this.RunCalculationsAndSetUpdatesAsync(currentElement); yield return(currentElement); } } } else if (this.GCCalculatorParams.DocToCalcReader.NodeType == XmlNodeType.EndElement) { if (this.GCCalculatorParams.DocToCalcReader.Name == OperationComponent.OPERATION_PRICE_TYPES.operationgroup.ToString() || this.GCCalculatorParams.DocToCalcReader.Name == OperationComponent.COMPONENT_PRICE_TYPES.componentgroup.ToString()) { break; } } } }