Exemple #1
0
        public string ApplyModifiers(Modifier [] listModifiers, RuleType ruleType)
        {
            if (listModifiers == null) {
            switch (ruleType){
            case RuleType.RESULT:
                return result_match;
            case RuleType.FULL:
                return full_match;
            }
            }

            string result;
            if (ruleType == RuleType.FULL) {
            result = full_match;

            foreach (Modifier modifier in listModifiers) {
                result = ApplyModifier (result, modifier);
            }
            } else {
            result = result_match;
            foreach (Modifier modifier in listModifiers) {
                result = ApplyModifier (result, modifier);
            }
            }
            return result;
        }
Exemple #2
0
 public void TestModifierWithoutParamsAttributes()
 {
     XmlNode node = document.SelectSingleNode ("/def:style/def:global/def:rule[7]/def:modifiers/def:modifier[1]", manager);
     Modifier mod = new Modifier (node, manager);
     Assert.AreEqual ("Trim", mod.Name, "TMWOPA1");
     Assert.IsNull (mod.Parameters, "TMWOPA2");
 }
 public void ApplyModifierResultConcatPostfix()
 {
     StringMatch resultMatch = new StringMatch (" Gomez ", " German ");
     Hashtable parameters = new Hashtable ();
     parameters ["postfix"] = "Castañeda";
     Modifier concat = new Modifier ("Concat", parameters);
     Assert.AreEqual (" German Castañeda", resultMatch.ApplyModifier (resultMatch.ResultMatch, concat));
 }
 public void ApplyModifierFullConcatPostfix()
 {
     StringMatch fullMatch = new StringMatch (" Gomez ", "");
     Hashtable parameters = new Hashtable ();
     parameters ["postfix"] = "Morales";
     Modifier concat = new Modifier ("Concat", parameters);
     Assert.AreEqual (" Gomez Morales", fullMatch.ApplyModifier (fullMatch.FullMatch, concat));
 }
Exemple #5
0
 public void TestModifierWithParamsAttributes()
 {
     XmlNode node = document.SelectSingleNode ("/def:style/def:global/def:rule[7]/def:modifiers/def:modifier[2]", manager);
     Modifier mod = new Modifier (node, manager);
     Assert.AreEqual ("Concat", mod.Name, "TMWPA1");
     Assert.AreEqual ("\n[key] ", mod.Parameters ["prefix"], "TMWPA2");
     Assert.AreEqual (" [/key]\n\n", mod.Parameters ["postfix"], "TMWPA3");
 }
Exemple #6
0
        public string ApplyModifier(string text,Modifier modifier)
        {
            string result = String.Empty;
            switch (modifier.Name) {
            case "Trim":
            result = text.Trim ();
            break;
            case "Concat":
            result = StringRegexp.Unescape ((string) modifier.Parameters ["prefix"]) + text + StringRegexp.Unescape ((string) modifier.Parameters ["postfix"]);
            break;
            case "TrimEnd":
            result = text.TrimEnd ();
            break;
            }

            return result;
        }
 public void ApplyModifiersFull()
 {
     StringMatch fullMatch = new StringMatch (" Gomez ", "");
     Hashtable parameters = new Hashtable ();
     parameters ["prefix"] = "Hector";
     parameters ["postfix"] = "Morales";
     Modifier trim = new Modifier ("Trim", null);
     Modifier concat = new Modifier ("Concat", parameters);
     Modifier [] modifiers = {trim, concat};
     Assert.AreEqual ("HectorGomezMorales", fullMatch.ApplyModifiers (modifiers, RuleType.FULL));
 }
 public void ApplyModifierResultTrim()
 {
     StringMatch resultMatch = new StringMatch ("\nFoo    ", "\n\n    Bar    \n");
     Modifier trim = new Modifier ("Trim", null);
     Assert.AreEqual ("Bar", resultMatch.ApplyModifier (resultMatch.ResultMatch, trim));
 }
 public void ApplyModifierFullTrim()
 {
     StringMatch fullMatch = new StringMatch ("\nFoo    ", "");
     Modifier trim = new Modifier ("Trim", null);
     Assert.AreEqual ("Foo", fullMatch.ApplyModifier (fullMatch.FullMatch, trim));
 }
Exemple #10
0
 public void ApplyModifiersResult2()
 {
     StringMatch fullMatch = new StringMatch (" Gomez ", " German ");
     Hashtable parameters = new Hashtable ();
     parameters ["prefix"] = "         Juan";
     parameters ["postfix"] = "Castañeda\n  \n";
     Modifier trim = new Modifier ("Trim", null);
     Modifier concat = new Modifier ("Concat", parameters);
     Modifier [] modifiers = {concat, trim};
     Assert.AreEqual ("Juan German Castañeda", fullMatch.ApplyModifiers (modifiers, RuleType.RESULT));
 }
Exemple #11
0
 public void ApplyModifiersFullConcatPrefix()
 {
     StringMatch fullMatch = new StringMatch (" Gomez ", "");
     Hashtable parameters = new Hashtable ();
     parameters ["prefix"] = "Hector";
     Modifier concat = new Modifier ("Concat", parameters);
     Assert.AreEqual ("Hector Gomez ", fullMatch.ApplyModifier (fullMatch.FullMatch, concat));
 }