public virtual List <AbstractElement> GetListOfConnectedElements(AbstractElement begin, List <AbstractElement> resList = null) { if (resList == null) // if list is no assigned, assign it { //Debug.Log("Assigning resList"); resList = new List <AbstractElement>(); } //Debug.Log(string.Format("Adding our element, {0}", Name)); resList.Add(this); if (this == begin) // if we reached the element from which we started, the list is complete { //Debug.Log(string.Format("END, returning resList with length {0} and elements {1}", resList.Count, resList.GetReadableList())); return(resList); } if (!Conductive) { // [reslist assigned, this is not beginning element, have no joints] //Debug.Log(string.Format("!!! Returning null, no joints in {0} object", Name)); resList.Remove(this); return(null); } // [reslist assigned, this is not beginning element, have joints] add this to reslist var allPaths = NextElements.Select(element => element.GetListOfConnectedElements(begin, resList)).ToList(); var totalResList = new List <AbstractElement>(); foreach ( var element in allPaths.Where(path => path != null) .SelectMany(path => path.Where(element => !totalResList.Contains(element)))) { totalResList.Add(element); } return(totalResList); }
public override bool Assert() { return(NextElements.All(x => { return (x.Type == ElementType.Input) | (x.Type == ElementType.Special); }) & NextElements.Count > 0); }
public override bool Assert() { return(NextElements.Where(x => { return x.Type == ElementType.Null; }).Count() == 1 && NextElements.Count == 1); }