Exemplo n.º 1
0
        public void ProcessText(string szPhrase)
        {
            string[] aWords = szPhrase.ToLower().Split().Reverse().ToArray();
            //we process the words back to front ....this works for english but...maybe for other languages not so good..
            //var wordsReversed = aWords.Reverse();
            int nItemCount = aWords.Length;
            //aWords = wordsReversed.ToArray();
            dynamic returnValue = null;

            for (int i = 0; i < nItemCount; ++i)
            {
                WordEntry entry = m_entries[aWords[i]];

                if (entry != null)
                {
                    returnValue = entry.Action(entry.StateObject, returnValue);
                }
            }
        }
Exemplo n.º 2
0
        public void AddAction(string szPrimaryWord, WordAction action, dynamic stateObject = null)
        {
            string[] aWords    = szPrimaryWord.Split();
            var      wordEntry = new WordEntry();
            var      key       = new WordKeyEntry();

            wordEntry.Action      = action;
            wordEntry.StateObject = stateObject;

            if (aWords.Length > 1)
            {
                for (int i = 0; i < aWords.Length; ++i)
                {
                }
            }
            else
            {
                m_entries.Add(szPrimaryWord.ToLower(), wordEntry);
            }
        }