public override int IsSatisfiedDeepBy(string value) { TreePartEndOf eof = null; var longestResult = -1; foreach (var leaf in this.Leafs) { if (leaf is TreePartEndOf) { if (eof != null) { throw new Exception("Only one end part can be in collection"); } eof = leaf as TreePartEndOf; continue; } var result = leaf.IsSatisfiedDeepBy(value); if (result == -1) { continue; } if (this._findLongest) { if (longestResult < result) { longestResult = result; } } else { return(result); } } if (longestResult > -1) { return(longestResult); } if (eof is null) { return(-1); } return(eof.IsSatisfiedDeepBy(value)); }
protected TreePart Create(TreePartEndOf t, string value) { if (t.IsSatisfiedTopBy(value)) { return(t); } var collection = new TreePartCollection(); collection.Leafs.Add(this.Create(new TreePartCondition(value[0]), value)); collection.Leafs.Add(t); return(collection); }