Exemplo n.º 1
0
 public void add(Element_Base new_child)
 {
     children.Add(new_child);
     new_child.parent   = this;
     new_child.document = document;
     //new_child.on_parented();
 }
Exemplo n.º 2
0
        void add_word(Element_Word word, Element_Base choice)
        {
            foreach (Element_Base item in choice.children)
            {
                if (word.text == item.word_text)
                {
                    choice.children.Remove(item);
                }
            }

            choice.add(word);

            List <Element_Base> vocabulary = new List <Element_Base>();

            vocabulary.AddRange(choice.children);

            vocabulary.Sort(delegate(Element_Base first, Element_Base second)
                            { return(first.word_text.CompareTo(second.word_text)); });

            choice.children.Clear();
            foreach (Element_Base item in vocabulary)
            {
                choice.children.Add(item);
            }
        }
Exemplo n.º 3
0
            public string check_source_for_property(Element_Base word, string key)
            {
                if (word == null)
                {
                    return(null);
                }

                if (word.GetType() == typeof(Element_Item))
                {
                    Element_Item item = word as Element_Item;
                    if (!item.properties.ContainsKey(key))
                    {
                        return(check_source_for_property(word.parent, key));
                    }

                    return(item.properties[key]);
                }
                else if (word.GetType() == typeof(Element_Word))
                {
                    Element_Word item = word as Element_Word;
                    if (!item.properties.ContainsKey(key))
                    {
                        return(check_source_for_property(word.parent, key));
                    }

                    return(item.properties[key]);
                }
                else
                {
                    return(check_source_for_property(word.parent, key));
                }
            }
Exemplo n.º 4
0
        public Element_Base create_child(Type type)
        {
            Element_Base result = (Element_Base)System.Activator.CreateInstance(type);

            add(result);
            //result.initialize(element);
            return(result);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        public void add_word(Element_Word word, string rule_name)
        {
            Element_Base rule = get_rule(rule_name);

            if (rule == null)
            {
                return;
            }

            add_word(word, rule.children[0]);
        }
Exemplo n.º 7
0
 public Old_Action(Element_Base new_parent)
 {
     parent   = new_parent;
     document = parent.document;
 }