// Called by an expression when it references another expression in the engine internal void AddDependency(string tailName, ExpressionContext context) { ExpressionResultPair actualTail = this.GetTail(tailName); string headName = context.CalcEngineExpressionName; ExpressionResultPair actualHead = this.GetTail(headName); // An expression could depend on the same reference more than once (ie: "a + a * a") MyDependencies.AddDepedency(actualTail, actualHead); }
/// <include file='Resources/DocComments.xml' path='DocComments/Member[@name="BatchLoader.Add"]/*' /> public void Add(string atomName, string expression, ExpressionContext context) { Utility.AssertNotNull(atomName, "atomName"); Utility.AssertNotNull(expression, "expression"); Utility.AssertNotNull(context, "context"); BatchLoadInfo info = new BatchLoadInfo(atomName, expression, context); MyNameInfoMap.Add(atomName, info); MyDependencies.AddTail(atomName); ICollection <string> references = this.GetReferences(expression, context); foreach (string reference in references) { MyDependencies.AddTail(reference); MyDependencies.AddDepedency(reference, atomName); } }
private void CloneDependentsInternal(T tail, DependencyManager <T> target, IDictionary <T, object> seenNodes) { if (seenNodes.ContainsKey(tail) == true) { // We've already added this node so just return return; } else { // Haven't seen this node yet; mark it as visited seenNodes.Add(tail, null); target.AddTail(tail); } IDictionary <T, object> innerDict = this.GetInnerDictionary(tail); // Do the recursive add foreach (T head in innerDict.Keys) { target.AddDepedency(tail, head); this.CloneDependentsInternal(head, target, seenNodes); } }