//it really boils my charcholes that I cant make this thing copy the root level: // A) it would force this object to be statically typed to TSubject, else it cant use the Proxyfactory's MakeVersioning() // B) I have to inject a proxy factory, a clone factory, and the object content (else I cant use ProxyFactory's MakeVersioning() // C) the visitor has no concept of a return type, and fundamentally since I'm trying to clone a tree I need to return the tree's clone. // D) it means another custom entry in IVisitorFactory (because this visitor will have to take constructor args) public override void OnEntry(IVersionControlNode controlNode) { Debug.Assert(controlNode.Mutations.IsOrderedBy(mutation => mutation.TimeStamp)); copyMutationHistoryIntoNewMemory(controlNode); updateChildrenToNewMemory(controlNode); }
public override void OnEntry(IVersionControlNode controlNode) { var relatedMutations = controlNode.Mutations.Where(mutation => mutation.TimeStamp > _targetTime); foreach (var mutation in relatedMutations) { mutation.IsActive = false; } }
public override void OnEntry(IVersionControlNode controlNode) { if (! VisitAllNodes && _hasRunOnce) { return; } _hasRunOnce = true; _descendents.Add(controlNode); }
public static void RecursiveAccept(IVersionControlNode hostingNode, IVersionControlTreeVisitor visitor) { visitor.OnEntry(hostingNode); // ReSharper disable ForCanBeConvertedToForeach -- might cause a concurrency issue. TODO for (var i = 0; i < hostingNode.Children.Count; i++) // ReSharper restore ForCanBeConvertedToForeach { hostingNode.Children[i].RecursiveAccept(visitor); } visitor.OnExit(hostingNode); }
private void updateChildrenToNewMemory(IVersionControlNode controlNode) { var candidatesByIndex = GetCadidatesByIndex(controlNode); var children = candidatesByIndex.GroupBy(mutation => mutation.Value.TargetSite) .Select(group => @group.Last()) .Select(mutation => mutation.Value.Arguments.Single().GetVersionControlNode()); controlNode.Children.Clear(); controlNode.Children.AddRange(children); }
private void copyMutationHistoryIntoNewMemory(IVersionControlNode controlNode) { var candidatesByIndex = GetCadidatesByIndex(controlNode); foreach (var indexCandidatePair in candidatesByIndex) { var versioningChild = indexCandidatePair.Value.Arguments.Single(); var versioningPropertyValueClone = versioningChild.GetVersionControlNode().CurrentDepthCopy(); controlNode.Mutations[indexCandidatePair.Key] = new TimestampedPropertyVersionDelta(indexCandidatePair.Value, versioningPropertyValueClone); } }
public static void Accept(IVersionControlNode hostingNode, IVersionControlTreeVisitor visitor) { visitor.OnFirstEntry(); hostingNode.RecursiveAccept(visitor); visitor.OnLastExit(); }
public virtual void OnExit(IVersionControlNode controlNode) { }
private IEnumerable<KeyValuePair<int, TimestampedPropertyVersionDelta>> GetCadidatesByIndex(IVersionControlNode node) { return from index in Enumerable.Range(0, node.Mutations.Count) where node.Mutations[index].IsSettingVersioningObject select new KeyValuePair<int, TimestampedPropertyVersionDelta>(index, node.Mutations[index]); }