public bool Contains(Graph.Edge r) { var ex = new ExcludeData(r); return(items .Where(m => m.parent?.UniqId == ex.parent?.UniqId && m.child?.UniqId == ex.child?.UniqId) .Any(m => m.Mergable(ex))); }
public void Merge(ExcludeData i) { if (i.from == null) { this.from = i.from; } if (i.to == null) { this.to = i.to; } if (this.from.HasValue && i.from.HasValue && i.from < this.from) { this.from = i.from; } if (this.to.HasValue && i.to.HasValue && i.to > this.to) { this.to = i.to; } }
public ExcludeDataCol AddItem(ExcludeData i) { var icoItems = items.Where(m => m.parent == i.parent && m.child == i.child); if (items.Count() > 0) { foreach (var it in icoItems) { if (it.Mergable(i)) { it.Merge(i); return(this); } } items.Add(i); } else { items.Add(i); } return(this); }
public bool Mergable(ExcludeData newI) { if (newI.from.HasValue && this.to.HasValue && this.to < newI.from ) { return(false); } if (newI.to.HasValue && this.from.HasValue && this.from > newI.to ) { return(false); } if (newI.from == null && newI.to == null) { return(true); } //at least in one interval if (this.from.HasValue && this.to.HasValue) { if (newI.from.HasValue && (newI.from >= this.from && newI.from <= this.to)) { return(true); } if (newI.to.HasValue && (newI.to >= this.from && newI.to <= this.to)) { return(true); } } else if (this.from.HasValue == false && this.to.HasValue) { if (newI.from.HasValue && (newI.from <= this.to)) { return(true); } if (newI.to.HasValue && (newI.to <= this.to)) { return(true); } } else if (this.from.HasValue && this.to.HasValue == false) { if (newI.from.HasValue && (newI.from >= this.from)) { return(true); } if (newI.to.HasValue && (newI.to >= this.from)) { return(true); } } else if (this.from.HasValue == false && this.to.HasValue == false) { return(true); } return(false); }