public void GetPossibleStrings() { if (!PossibleStrings.Any() && !string.IsNullOrEmpty(Value)) { PossibleStrings.Add(Value); return; } else if (PossibleStrings.Any()) { return; } ChildRules.ForEach(cr => cr.GetPossibleStrings()); AlternativeChildRules.ForEach(cr => cr.GetPossibleStrings()); if (ChildRules.Count == 1 && ChildRules.First().PossibleStrings.Any()) { foreach (var fc in ChildRules.Last().PossibleStrings) { PossibleStrings.Add(fc); } } if (ChildRules.Count == 2) { if (ChildRules.First().PossibleStrings.Any() && ChildRules.Last().PossibleStrings.Any()) { foreach (var fc in ChildRules.First().PossibleStrings) { foreach (var sc in ChildRules.Last().PossibleStrings) { PossibleStrings.Add(fc + sc); } } } } if (AlternativeChildRules.Count == 1 && AlternativeChildRules.First().PossibleStrings.Any()) { foreach (var fc in AlternativeChildRules.Last().PossibleStrings) { PossibleStrings.Add(fc); } } if (AlternativeChildRules.Count == 2) { if (AlternativeChildRules.First().PossibleStrings.Any() && AlternativeChildRules.Last().PossibleStrings.Any()) { foreach (var fc in AlternativeChildRules.First().PossibleStrings) { foreach (var sc in AlternativeChildRules.Last().PossibleStrings) { PossibleStrings.Add(fc + sc); } } } } }
public override Rule Clone(Predicate <Selector> filter) { var r = new DirectiveRule { ChildRules = ChildRules == null ? null : ChildRules.Select(x => x.Clone(filter)).Where(x => x != null).ToList(), Selector = Selector == null ? null : (DirectiveSelector)Selector.Clone(ExpectedBodyType == BodyType.Properties?filter:null), Properties = Properties == null ? null : Properties.Select(x => x.Clone()).ToList(), }; if (filter != null && (r.ChildRules == null || r.ChildRules.Count == 0 || Selector == null)) { return(null); } r.SetParsingSource(this); return(r); }