Esempio n. 1
0
        protected override void load(WordList wl)
        {
            fileReader = new StreamReader(strFilename);
            String strLine = null;

            while (!fileReader.EndOfStream)
            {
                WordEntry we = new WordEntry();
                strLine = fileReader.ReadLine();
                String[] fields = strLine.Split(delimiter);

                // First entry is the word
                we.setWord(fields[0]);

                // Second come the meanings.Here,we have to parse again
                String[] attrs = fields[1].Split(newline);
                foreach (String str in attrs)
                {
                    we.addMeaning(str);
                }

                // Third come the usages.
                if (fields.Length > 2)
                {
                    attrs = fields[2].Split(newline);
                    foreach (String str in attrs)
                    {
                        we.addUsage(str);
                    }
                }

                // Fourth come the Other info.
                if (fields.Length > 3)
                {
                    attrs = fields[3].Split(newline);
                    foreach (String str in attrs)
                    {
                        we.addOtherInfo(str);
                    }
                }

                // Now we have the entry ready. Add it to the word list
                wl.addEntry(we);
            }
            fileReader.Close();
            fileReader = null;
        }
Esempio n. 2
0
        // abstract method implementation
        protected override void load(WordList wl)
        {
            XmlDocument   xd  = new XmlDocument();
            XmlTextReader xtr = new XmlTextReader(strFilename);

            xtr.Read();
            xd.Load(xtr);
            XmlNodeList xnl = xd.GetElementsByTagName(strWordEntryMoniker);

            iTotalWords = xnl.Count;
            foreach (XmlNode xn in xnl)
            {
                WordEntry we = new WordEntry();
                foreach (XmlNode xnSubElements in xn.ChildNodes)
                {
                    if (xnSubElements.Name == strWordMoniker)
                    {
                        we.setWord(xnSubElements.InnerText);
                    }
                    else if (xnSubElements.Name == strMeaningMoniker)
                    {
                        we.addMeaning(xnSubElements.InnerText);
                    }
                    else if (xnSubElements.Name == strUsageMoniker)
                    {
                        we.addUsage(xnSubElements.InnerText);
                    }
                    else if (xnSubElements.Name == strOtherInfoMoniker)
                    {
                        we.addOtherInfo(xnSubElements.InnerText);
                    }
                }
                wl.addEntry(we);
                iWordsLoaded++;
            }
        }