private void ReplaceEntries(FormulaDecorator formula, string str) { string[] sep = { Substring.Value }; var strs = str.Split(sep, StringSplitOptions.None); bool emptyLast = strs.Last().Length == 0; strs = strs.Where(s => s.Length > 0).ToArray(); for (int i = 0; i < strs.Length; ++i) { var concatC = new ConcatDecorator(new Const(strs[i])); concatC.Subformula = formula.Subformula; formula.Subformula = concatC; if (i < strs.Length - 1 || emptyLast) { Assert.IsTrue(Replacement.IsVar); var concatV = new ConcatDecorator(new Var(Replacement.Value)); concatV.Subformula = formula.Subformula; formula.Subformula = concatV; } } ToLeave = true; }
public void Visit(ConcatDecorator f) { Replace(f); if (f.ConcatValue.IsConst == Substring.IsConst) { if (Substring.IsConst && Replacement.IsConst || f.ConcatValue.Value == Substring.Value) { f.ConcatValue.Value = f.ConcatValue.Value.Replace(Substring.Value, Replacement.Value); f.ConcatValue.IsConst = Replacement.IsConst; } else if (Substring.IsConst) { ReplaceEntries(f, f.ConcatValue.Value); } } }
public void Visit(ConcatDecorator f) { rv.Visit(f); }