예제 #1
0
        /// <summary>
        /// Recalculates this instance.
        /// </summary>
        /// <param name="maxCalcCount">The max iterator.</param>
        /// <param name="forceRecalculateAll">Whether force recalculate all formula in current manager.</param>
        /// <returns><see langword="true" /> if all dirty nodes have been recalculated, otherwise, <see langword="false" /></returns>
        public bool Recalculate(int maxCalcCount = 0xc350, bool forceRecalculateAll = false)
        {
            if (forceRecalculateAll)
            {
                this.ClearDirtyItem();
                foreach (CalcCalculationManager manager in this._calcManagers.Values)
                {
                    if (manager.FormulaCount > 0)
                    {
                        manager.InvalidateAllIdentity();
                        maxCalcCount += manager.FormulaCount;
                    }
                }
            }
            int num = 0;

            while ((this._headerDirtyItems != null) && (num < maxCalcCount))
            {
                DirtyItem dirtyItem        = this._headerDirtyItems;
                CalcCalculationManager mgr = this.GetCalculationManager(dirtyItem.Source, null, true);
                this.EvaluateFormula(mgr, dirtyItem);
                CalcNode objA = dirtyItem.Node;
                if (object.ReferenceEquals(objA, null))
                {
                    objA = mgr.Graph.GetNode(dirtyItem.Id);
                }
                if (!object.ReferenceEquals(objA, null))
                {
                    objA.ClearDirty();
                    if (dirtyItem == this._headerDirtyItems)
                    {
                        this.RemoveDirtyItem(dirtyItem);
                    }
                }
                else
                {
                    this.RemoveDirtyItem(dirtyItem);
                }
                num++;
            }
            return(num < maxCalcCount);
        }