コード例 #1
0
        /// <summary>
        /// Add new sentence but kick off previous one, use to handle backoff.
        /// </summary>
        /// <param name="sentence">Sentence.</param>
        public void AddwithOverwrite(UnitLatticeSentence sentence)
        {
            foreach (UnitLatticeSentence sent in Sentences)
            {
                if (sent.Id == sentence.Id)
                {
                    Sentences.Remove(sent);
                    break;
                }
            }

            Sentences.Add(sentence);
        }
コード例 #2
0
        /// <summary>
        /// Performance loading.
        /// </summary>
        /// <param name="reader">Stream reader.</param>
        /// <param name="contentController">Content controller.</param>
        protected override void PerformanceLoad(StreamReader reader, object contentController)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            XmlTextReader xmlTextReader = new XmlTextReader(reader);
            while (xmlTextReader.Read())
            {
                if (xmlTextReader.NodeType == XmlNodeType.Element && xmlTextReader.Name == "sentences")
                {
                    Language = Localor.StringToLanguage(xmlTextReader.GetAttribute("lang"));
                }
                else if (xmlTextReader.NodeType == XmlNodeType.Element && xmlTextReader.Name == "sentence")
                {
                    UnitLatticeSentence sentence = new UnitLatticeSentence();
                    sentence.Load(xmlTextReader, contentController);

                    this.Sentences.Add(sentence);
                }
            }
        }