public void AddParent(RevisionGraphRevision parent, out int maxScore) { // Generate a LaneColor used for rendering if (Parents.Any()) { parent.LaneColor = parent.Score; } else { if (parent.LaneColor == -1) { parent.LaneColor = LaneColor; } } if (IsRelative) { parent.MakeRelative(); } Parents.Add(parent); parent.AddChild(this); maxScore = parent.EnsureScoreIsAbove(Score + 1); StartSegments.Add(new RevisionGraphSegment(parent, this)); }
// Mark this commit, and all its parents, as relative. Used for branch highlighting. // By default, the current checkout will be marked relative. public void MakeRelative() { if (IsRelative) { return; } if (!Parents.Any()) { IsRelative = true; return; } var stack = new Stack <RevisionGraphRevision>(); stack.Push(this); while (stack.Count > 0) { var revision = stack.Pop(); revision.IsRelative = true; foreach (var parent in revision.Parents.Where(r => !r.IsRelative)) { stack.Push(parent); } } }
public bool RemoveParent(ElementModel parent) { bool success = Parents.Remove(parent.Id); parent.RemoveChild(this); if (!Parents.Any()) { //We are now orphaned and need to clean up if (IsLeaf) { //We are at the bottom and just need to remove our lights Lights.Clear(); OnPropertyChanged(nameof(LightCount)); } else { foreach (var child in Children.ToList()) { child.RemoveParent(this); } } } return(success); }
public void AddPrent(Record parent) { if (!Parents.Any(r => r.Equals(parent))) { Parents.Add(parent); } }
public bool CanAddParent(Person parent) { if (Parents.Count() == 2) { return(false); } return(!Parents.Any(m => m.Gender == parent.Gender)); }
private void DeleteParent(Node node) { Parents.Remove(node); if (!Parents.Any()) { Ready = true; } }
private string ResolveInheritance() { if (Parents.Any()) { return($" : {Parents.Distinct().OrderBy(i => i).Aggregate((x, y) => $"{x}, {y}")}"); } return(string.Empty); }
internal void AppendTo(Node parent) { if (parent == null) { throw new ArgumentNullException("parent", "Argument(parent) is null!"); } if (!Parents.Any(p => p.Id.Equals(parent.Id))) { Parents.Add(parent); } }
public override string ToString() { StringBuilder sb = new StringBuilder(); sb.AppendLine(MainPerson.ToString()); sb.AppendLine("Parents:"); if (Parents.Any()) { sb.AppendLine(string.Join(Environment.NewLine, Parents)); } sb.AppendLine("Children:"); sb.AppendLine(string.Join(Environment.NewLine, Children)); return(sb.ToString().TrimEnd()); }
public void WriteXml(TextWriter w) { w.WriteLine($" <e name='{ActualElementName}' api-level='{ApiLevel}'>"); if (Parents != null && Parents.Any()) { foreach (var p in Parents) { w.WriteLine($" <parent>{p.ToActualName ()}</parent>"); } } foreach (var a in Attributes) { a.WriteXml(w); } w.WriteLine(" </e>"); }
/// <summary> /// This operation is implemented to remain consistent with the IDictionary version. /// If the intent is only to remove a given KeyValuePair from the top-level collection, /// then Remove(..) should be used instead. /// </summary> /// <param name="item">The KeyValuePair to remove.</param> /// <returns>A boolean value indicating if the item was found and removed.</returns> public bool RemoveDeeply(KeyValuePair <TKey, TValue> item) { lock (_syncRoot) { // if we find it at the top-level, the we are done if (_localEntries.Remove(item)) { return(true); } // try the parents if (Parents.Any(parent => parent.RemoveDeeply(item))) { return(true); } // try the defaults return(LocalDefaults.Remove(item)); } }
/// <summary> /// This checks "deeply" for the specified item. /// That is, it tried first to find it in the top-level dictionary, /// then it checks each of the parents, then it checks defaults if they exist. /// If a "shallow" check is required, call "Shallow().Contains()" instead. /// </summary> /// <param name="item">The KeyValuePair of interest.</param> /// <returns>A boolean value indicating it the item was found.</returns> public bool Contains(KeyValuePair <TKey, TValue> item) { lock (_syncRoot) { // if the item exists at the top level, then we're done if (_localEntries.Contains(item)) { return(true); } // it doesn't really matter in what order the parents are searched (we either find it or not) if (Parents.Any(parent => (parent as ICollection <KeyValuePair <TKey, TValue> >).Contains(item))) { return(true); } // lastly we need to check Defaults return(LocalDefaults != null && (LocalDefaults as ICollection <KeyValuePair <TKey, TValue> >).Contains(item)); } }
public override bool RemoveFromParent(GroupNode <Element> parent, bool cleanup) { bool result = base.RemoveFromParent(parent, cleanup); // if we're cleaning up after removal (eg. being deleted), and we're actually floating // (ie. this node doesn't exist anywhere else), remove the associated element (if any) if (cleanup && !Parents.Any()) { if (Element != null) { VixenSystem.Elements.RemoveElement(Element); foreach (var source in Properties.ToArray()) { Properties.Remove(source.Descriptor.TypeId); } Element = null; } VixenSystem.Nodes.ClearElementNode(Id); } OnChanged(this); return(result); }
// This method is called to ensure that the score is higher than a given score. // E.g. the score needs to be higher that the score of its children. public int EnsureScoreIsAbove(int minimalScore) { if (minimalScore <= Score) { return(Score); } Score = minimalScore; if (!Parents.Any()) { return(Score); } int maxScore = Score; var processed = new HashSet <RevisionGraphRevision>(); var stack = new Stack <RevisionGraphRevision>(); stack.Push(this); processed.Add(this); while (stack.Count > 0) { var revision = stack.Pop(); foreach (var parent in revision.Parents.Where(r => r.Score < maxScore + 1 && !processed.Contains(r))) { parent.Score = maxScore + 1; maxScore = parent.Score; processed.Add(parent); stack.Push(parent); } } return(maxScore); }
// This method is called to ensure that the score is higher than a given score. // E.g. the score needs to be higher that the score of its children. public int EnsureScoreIsAbove(int minimalScore) { if (minimalScore <= Score) { return(Score); } Score = minimalScore; if (!Parents.Any()) { return(Score); } int maxScore = Score; var stack = new Stack <RevisionGraphRevision>(); stack.Push(this); while (stack.Count > 0) { var revision = stack.Pop(); foreach (var parent in revision.Parents.Where(r => r.Score <= revision.Score)) { parent.Score = revision.Score + 1; Debug.Assert(parent.Score > revision.Score, "Reorder score failed."); maxScore = Math.Max(parent.Score, maxScore); stack.Push(parent); } } return(maxScore); }
private int CalculateStatus() { try { var status = (int)NodeStatus.None; if (CanInput) { switch (this.NodeType) { case NodeType.Start: case NodeType.Normal: var details = Details; status = (details == null || details.Length == 0) ? (int)NodeStatus.Disable : Rule4Status.GetStatus(details, Context.Task.Variables); break; case NodeType.Control: case NodeType.End: status = this.Data != null ? (int)NodeStatus.Approved : (int)NodeStatus.Disable; break; } } else { if (Parents.Any(n => n.Status == (int)NodeStatus.Error)) { throw new ApplicationException("Parent nodes contain error status!"); } status = (Parents.Count(n => n.Status == (int)NodeStatus.Disable) == Parents.Count) ? (int)NodeStatus.Disable : (int)NodeStatus.None; } return(status); } catch (Exception err) { return((int)NodeStatus.Error); } }
public bool IsDirectDescendantOf(Revision revision) { EnsureParentRevisionInfo(); //TODO: this is only checking direct descendant return(Parents.Any(p => p.Hash == revision.Number.Hash)); }
public IEnumerable <PField> GetAllFKs() { return(this.Where(_ => Parents.Any(f => f.FK.ReferencedColumn == _.FieldName))); }
private bool ParentHasSameType(Type type) { return(Parents.Any((HierarchyPropertyNode x) => x.Property.PropertyType == type)); }
public bool InheritsFrom(Type t) { return(this == t || Parents.Any(p => p.InheritsFrom(t))); }
public bool IsRootNode() { return(!Parents.Any()); }