public Element_Base create_child(XmlElement element)
        {
            Element_Base result = null;

            switch (element.Name.ToLower())
            {
            case "rule":
            {
                result = new Element_Item();
                document.all_rules.Add((Element_Item)result);
                break;
            }

            case "ruleref":
            case "reference":
                result = new Element_Reference();
                break;

            case "tag":
                result = new Element_Tag();
                break;

            case "item":
                result = new Element_Item();
                if (result.name != "")
                {
                    document.all_rules.Add((Element_Item)result);
                }
                break;

            case "one-of":
            case "choice":
                result = new Element_Choice();
                break;

            case "dictation":
                result = new Element_Dictation();
                break;

            case "word":
                result = new Element_Word();
                break;

            //case "filter":
            //    if (Familiar_Word.Filter.filters.has_key(element.InnerText))
            //        filters.Add(Familiar_Word.Filter.filters[element.InnerText]);
            //    return null;
            default:
                return(null);
            }

            add(result);
            result.initialize(element);
            return(result);
        }
Example #2
0
        public Element_Choice get_rule_choice(string rule_id)
        {
            Element_Item rule = get_rule(rule_id);

            if (rule == null)
            {
                return(null);
            }

            foreach (Element_Base element in rule.children)
            {
                if (element.GetType() == typeof(Element_Choice))
                {
                    return((Element_Choice)element);
                }
            }

            Element_Choice choices = (Element_Choice)rule.create_child(typeof(Element_Choice));

            rule.children.Add(choices);
            return(choices);
        }