public override Node Execute(Node node, out bool visitDeeper) { Rule rule = node as Rule; if (rule != null) { visitDeeper = false; string ruleName = (rule.Name ?? "").ToLowerInvariant(); foreach (Prefix prefix in PrefixesToProcess) { if (ruleName.StartsWith(prefix.PrefixString)) { if (!prefix.KeepRule) { return(null); } if (prefix.RemovePrefix) { rule.Name = rule.Name.Substring(prefix.PrefixString.Length); } if (prefix.Reverse) { if (rule.Name.IndexOf("right", StringComparison.InvariantCultureIgnoreCase) >= 0) { rule.Name = Replace(rule.Name, "right", "left", StringComparison.InvariantCultureIgnoreCase); return(rule); } if (rule.Name.IndexOf("left", StringComparison.InvariantCultureIgnoreCase) >= 0) { rule.Name = Replace(rule.Name, "left", "right", StringComparison.InvariantCultureIgnoreCase); return(rule); } if (rule.Name.IndexOf("top", StringComparison.InvariantCultureIgnoreCase) >= 0 || rule.Name.IndexOf("bottom", StringComparison.InvariantCultureIgnoreCase) >= 0) { return(rule); } ValuesReverserVisitor reverser = new ValuesReverserVisitor(); return(reverser.ReverseRule(rule)); } else { return(rule); } } } } visitDeeper = true; return(node); }
public override Node Execute(Node node, out bool visitDeeper) { Rule rule = node as Rule; if (rule != null) { visitDeeper = false; string ruleName = (rule.Name ?? "").ToLowerInvariant(); foreach (Prefix prefix in PrefixesToProcess) { if (ruleName.StartsWith(prefix.PrefixString)) { if (!prefix.KeepRule) { return null; } if (prefix.RemovePrefix) { rule.Name = rule.Name.Substring(prefix.PrefixString.Length); } if (prefix.Reverse) { if (rule.Name.IndexOf("right", StringComparison.InvariantCultureIgnoreCase) >= 0) { rule.Name = Replace(rule.Name, "right", "left", StringComparison.InvariantCultureIgnoreCase); return rule; } if (rule.Name.IndexOf("left", StringComparison.InvariantCultureIgnoreCase) >= 0) { rule.Name = Replace(rule.Name, "left", "right", StringComparison.InvariantCultureIgnoreCase); return rule; } if (rule.Name.IndexOf("top", StringComparison.InvariantCultureIgnoreCase) >= 0 || rule.Name.IndexOf("bottom", StringComparison.InvariantCultureIgnoreCase) >= 0) { return rule; } ValuesReverserVisitor reverser = new ValuesReverserVisitor(); return reverser.ReverseRule(rule); } else { return rule; } } } } visitDeeper = true; return node; }