Exemple #1
0
        public AttitudeList(FileStrBuff file)
        {
            string    tok;
            ArrayList att = new ArrayList(5);

            while (!file.Eof() && (tok = file.GetNextToken()) != "{")
            {
                try
                {
                    att.Add(Enum.Parse(typeof(Attitude), tok, true));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            if (file.Eof())
            {
                return;
            }

            file.Seek(-1);
            m_Strings = KeywordCollection.MakeList(file);
            if (att.Count > 0)
            {
                m_Atts = (Attitude[])att.ToArray(typeof(Attitude));
            }
            else
            {
                m_Strings = null;
            }
        }
Exemple #2
0
        public NotorietyList(FileStrBuff file)
        {
            string    tok;
            ArrayList noto = new ArrayList(5);

            while (!file.Eof() && (tok = file.GetNextToken()) != "{")
            {
                try
                {
                    noto.Add(Enum.Parse(typeof(NotoVal), tok, true));
                }
                catch
                {
                }
            }

            if (file.Eof())
            {
                return;
            }

            file.Seek(-1);
            m_Strings = KeywordCollection.MakeList(file);
            if (noto.Count > 0)
            {
                m_Notos = (NotoVal[])noto.ToArray(typeof(NotoVal));
            }
            else
            {
                m_Strings = null;
            }
        }
Exemple #3
0
        public KeywordCollection(FileStrBuff file)
        {
            m_Keys = new ArrayList();

            file.SkipUntil('{');
            file.NextChar();

            int brace = 1;
            while (!file.Eof() && brace > 0)
            {
                string tok = file.GetNextToken();
                switch (tok[0])
                {
                    case '#':
                        {
                            if (tok.ToLower() != "#key")
                            {
                                //Console.WriteLine( "KeywordCollection : Unknown command '{0}'", tok );
                                continue;
                            }

                            StringBuilder keyExp = new StringBuilder();
                            int count = 0;
                            while (!file.Eof() && (tok = file.GetNextToken()) != "{")
                            {
                                if (tok[0] == '@')
                                {
                                    if (tok == "@InternalGreeting")
                                    {
                                        if (count > 0)
                                            keyExp.Append("|");
                                        count += 7;
                                        keyExp.Append("(*hi*)|(*hello*)|(*hail*)|(*greeting*)|(*how*((*you*)|(*thou*)))|(*good*see*thee*)");
                                    }

                                    continue;
                                }
                                else
                                {
                                    count++;
                                    if (count > 1)
                                        keyExp.Append("|");
                                    keyExp.AppendFormat("({0})", tok);
                                }
                            }

                            if (!file.Eof())
                            {
                                file.Seek(-1); // leave the { in the input

                                IStringList[] lists = MakeList(file);
                                //Console.WriteLine( "KC '{0}' loaded {1} sub-lists...", exp, lists.Length );
                                if (lists != null && keyExp.Length > 0)
                                {
                                    keyExp.Replace("*", ".*");
                                    string exp = keyExp.ToString();
                                    if (exp != null && exp.Length > 0)
                                        m_Keys.Add(new Keyword(exp, lists));
                                }
                            }
                            break;
                        }
                    case '{':
                        brace++;
                        break;
                    case '}':
                        brace--;
                        break;
                    default:
                        //Console.WriteLine( "KeywordCollection : Unknown token '{0}'", tok );
                        break;
                }
            }
        }
Exemple #4
0
        public AttitudeList(FileStrBuff file)
        {
            string tok;
            ArrayList att = new ArrayList(5);
            while (!file.Eof() && (tok = file.GetNextToken()) != "{")
            {
                try
                {
                    att.Add(Enum.Parse(typeof(Attitude), tok, true));
                }
                catch
                {
                }
            }

            if (file.Eof())
                return;

            file.Seek(-1);
            m_Strings = KeywordCollection.MakeList(file);
            if (att.Count > 0)
                m_Atts = (Attitude[])att.ToArray(typeof(Attitude));
            else
                m_Strings = null;
        }
Exemple #5
0
        public NotorietyList(FileStrBuff file)
        {
            string tok;
            ArrayList noto = new ArrayList(5);
            while (!file.Eof() && (tok = file.GetNextToken()) != "{")
            {
                try
                {
                    noto.Add(Enum.Parse(typeof(NotoVal), tok, true));
                }
                catch
                {
                }
            }

            if (file.Eof())
                return;

            file.Seek(-1);
            m_Strings = KeywordCollection.MakeList(file);
            if (noto.Count > 0)
                m_Notos = (NotoVal[])noto.ToArray(typeof(NotoVal));
            else
                m_Strings = null;
        }
Exemple #6
0
        public KeywordCollection(FileStrBuff file)
        {
            m_Keys = new ArrayList();

            file.SkipUntil('{');
            file.NextChar();

            int brace = 1;

            while (!file.Eof() && brace > 0)
            {
                string tok = file.GetNextToken();
                switch (tok[0])
                {
                case '#':
                {
                    if (tok.ToLower() != "#key")
                    {
                        //Console.WriteLine( "KeywordCollection : Unknown command '{0}'", tok );
                        continue;
                    }

                    StringBuilder keyExp = new StringBuilder();
                    int           count  = 0;
                    while (!file.Eof() && (tok = file.GetNextToken()) != "{")
                    {
                        if (tok[0] == '@')
                        {
                            if (tok == "@InternalGreeting")
                            {
                                if (count > 0)
                                {
                                    keyExp.Append("|");
                                }
                                count += 7;
                                keyExp.Append("(*hi*)|(*hello*)|(*hail*)|(*greeting*)|(*how*((*you*)|(*thou*)))|(*good*see*thee*)");
                            }

                            continue;
                        }
                        else
                        {
                            count++;
                            if (count > 1)
                            {
                                keyExp.Append("|");
                            }
                            keyExp.AppendFormat("({0})", tok);
                        }
                    }

                    if (!file.Eof())
                    {
                        file.Seek(-1);                                   // leave the { in the input

                        IStringList[] lists = MakeList(file);
                        //Console.WriteLine( "KC '{0}' loaded {1} sub-lists...", exp, lists.Length );
                        if (lists != null && keyExp.Length > 0)
                        {
                            keyExp.Replace("*", ".*");
                            string exp = keyExp.ToString();
                            if (exp != null && exp.Length > 0)
                            {
                                m_Keys.Add(new Keyword(exp, lists));
                            }
                        }
                    }
                    break;
                }

                case '{':
                    brace++;
                    break;

                case '}':
                    brace--;
                    break;

                default:
                    //Console.WriteLine( "KeywordCollection : Unknown token '{0}'", tok );
                    break;
                }
            }
        }