public void ValidateIcuRules_ValidIcu_ReturnsTrue() { string message; Assert.IsTrue(_icuParser.ValidateIcuRules("&a < b <<< c < e/g\n&[before 1]m<z", out message)); Assert.AreEqual(string.Empty, message); }
private void WriteCollationRulesFromICUString(XmlWriter writer, XmlReader reader, string icu) { Debug.Assert(writer != null); icu = icu ?? string.Empty; if (reader != null) { // don't copy any alias that would override our rules if (FindElement(reader, "alias")) { reader.Skip(); } CopyUntilElement(writer, reader, "settings"); // for now we'll omit anything in the suppress_contractions and optimize nodes FindElement(reader, "special"); } IcuRulesParser parser = new IcuRulesParser(false); string message; // avoid throwing exception, just don't save invalid data if (!parser.ValidateIcuRules(icu, out message)) { return; } parser.WriteIcuRules(writer, icu); }
public static bool ValidateSortRules(string rules, out string message) { IcuRulesParser parser = new IcuRulesParser(); if (!parser.ValidateIcuRules(rules, out message)) { return false; } try { new IcuRulesCollator(rules); } catch (Exception e) { message = String.Format("Invalid ICU sort rules: {0}", e.Message); return false; } return true; }
private void WriteCollationRulesFromICUString(XmlWriter writer, string icu) { icu = icu ?? string.Empty; IcuRulesParser parser = new IcuRulesParser(false); string message; // avoid throwing exception, just don't save invalid data if (!parser.ValidateIcuRules(icu, out message)) { return; } parser.WriteIcuRules(writer, icu); }
private void WriteCollationRulesFromICUString(XmlWriter writer, XmlReader reader, string icu) { Debug.Assert(writer != null); icu = icu ?? string.Empty; if (reader != null) { // don't copy any alias that would override our rules if (FindElement(reader, "alias")) { reader.Skip(); } CopyUntilElement(writer, reader, "settings"); // for now we'll omit anything in the suppress_contractions and optimize nodes FindElement(reader, "special"); } IcuRulesParser parser = new IcuRulesParser(false); string message; // avoid throwing exception, just don't save invalid data if (!parser.ValidateIcuRules(icu, out message)) { return; } parser.WriteIcuRules(writer, icu); }