コード例 #1
0
        internal BatchLoadInfo[] GetBachInfos()
        {
            string[]       tails   = MyDependencies.GetTails();
            Queue <string> sources = MyDependencies.GetSources(tails);

            IList <string> result = MyDependencies.TopologicalSort(sources);

            BatchLoadInfo[] infos = new BatchLoadInfo[result.Count];

            for (int i = 0; i <= result.Count - 1; i++)
            {
                infos[i] = MyNameInfoMap[result[i]];
            }

            return(infos);
        }
コード例 #2
0
        /// <include file='Resources/DocComments.xml' path='DocComments/Member[@name="CalculationEngine.Recalculate"]/*' />
        public void Recalculate(params string[] roots)
        {
            // Get the tails corresponding to the names
            ExpressionResultPair[] rootTails = this.GetRootTails(roots);
            // Create a dependency list based on the tails
            DependencyManager <ExpressionResultPair> tempDependents = MyDependencies.CloneDependents(rootTails);
            // Get the sources (ie: nodes with no incoming edges) since that's what the sort requires
            Queue <ExpressionResultPair> sources = tempDependents.GetSources(rootTails);
            // Do the topological sort
            IList <ExpressionResultPair> calcList = tempDependents.TopologicalSort(sources);

            NodeEventArgs args = new NodeEventArgs();

            // Recalculate the sorted expressions
            foreach (ExpressionResultPair pair in calcList)
            {
                pair.Recalculate();
                args.SetData(pair.Name, pair.ResultAsObject);
                if (NodeRecalculated != null)
                {
                    NodeRecalculated(this, args);
                }
            }
        }