private bool VisitNodeReferences(esVisitParameters p) { Type type = p.Node.Obj.GetType(); esVisitableNode parent = p.Parent; esVisitableNode node = p.Node; p.Node = new esVisitableNode(); p.Parent = new esVisitableNode(); try { if (!typeof(String).IsAssignableFrom(type) && typeof(IEnumerable).IsAssignableFrom(type)) { p.Parent = node; int i = 0; foreach (object item in (IEnumerable)node.Obj) { p.Node.Obj = item; p.Node.PropertyName = ""; p.ProcessChildren = true; if (!VisitNode(p)) { return(false); } i++; } } if (typeof(IVisitable).IsAssignableFrom(type)) { esVisitableNode[] nodes = ((IVisitable)node.Obj).GetGraph(enterCallback); if (nodes != null) { p.Parent = node; for (int i = 0; i < nodes.Length; i++) { p.Node = nodes[i]; p.ProcessChildren = true; if (!VisitNode(p)) { return(false); } } } } } finally { p.Parent = parent; p.Node = node; } return(true); }
private bool AddIfNewReference(esVisitableNode node) { for (int i = 0; i < references.Count; i++) { if (Object.ReferenceEquals(node.Obj, references[i])) { // existing reference return(false); } } // add at beginning of list assuming that more recent items will collide first references.Insert(0, node.Obj); return(true); }
private bool AddIfNewReference(esVisitableNode node) { for (int i = 0; i < references.Count; i++) { if (Object.ReferenceEquals(node.Obj, references[i])) { // existing reference return false; } } // add at beginning of list assuming that more recent items will collide first references.Insert(0, node.Obj); return true; }