Esempio n. 1
0
        public static IStringList[] MakeList(FileStrBuff file)
        {
            file.SkipUntil('{');
            file.NextChar();
            int brace = 1;

            ArrayList list = new ArrayList();
            while (!file.Eof() && brace > 0)
            {
                string tok = file.GetNextToken();
                switch (tok[0])
                {
                    case '{':
                        brace++;
                        break;
                    case '}':
                        brace--;
                        break;
                    case '#':
                        {
                            string lwr = tok.ToLower();
                            if (lwr == "#attitude")
                                list.Add(new AttitudeList(file));
                            else if (lwr == "#notoriety")
                                list.Add(new NotorietyList(file));
                            //else
                            //	Console.WriteLine( "MakeList : Unknown token '{0}'", lwr );
                            break;
                        }
                    default:
                        {
                            PhraseList pl = new PhraseList();
                            pl.Add(tok);
                            //if ( brace <= 0 )
                            //	Console.WriteLine( "MakeList : Warning, no opening brace for PhraseList." );
                            while (!file.Eof() && brace > 0)
                            {
                                tok = file.GetNextToken();
                                if (tok == "{")
                                    brace++;
                                else if (tok == "}")
                                    brace--;
                                else
                                    pl.Add(tok);
                            }
                            list.Add(pl);
                            break;
                        }
                }
            }//while

            if (list.Count > 0)
                return (IStringList[])list.ToArray(typeof(IStringList));
            else
                return null;
        }
Esempio n. 2
0
        public static IStringList[] MakeList(FileStrBuff file)
        {
            file.SkipUntil('{');
            file.NextChar();
            int brace = 1;

            ArrayList list = new ArrayList();

            while (!file.Eof() && brace > 0)
            {
                string tok = file.GetNextToken();
                switch (tok[0])
                {
                case '{':
                    brace++;
                    break;

                case '}':
                    brace--;
                    break;

                case '#':
                {
                    string lwr = tok.ToLower();
                    if (lwr == "#attitude")
                    {
                        list.Add(new AttitudeList(file));
                    }
                    else if (lwr == "#notoriety")
                    {
                        list.Add(new NotorietyList(file));
                    }
                    //else
                    //	Console.WriteLine( "MakeList : Unknown token '{0}'", lwr );
                    break;
                }

                default:
                {
                    PhraseList pl = new PhraseList();
                    pl.Add(tok);
                    //if ( brace <= 0 )
                    //	Console.WriteLine( "MakeList : Warning, no opening brace for PhraseList." );
                    while (!file.Eof() && brace > 0)
                    {
                        tok = file.GetNextToken();
                        if (tok == "{")
                        {
                            brace++;
                        }
                        else if (tok == "}")
                        {
                            brace--;
                        }
                        else
                        {
                            pl.Add(tok);
                        }
                    }
                    list.Add(pl);
                    break;
                }
                }
            }            //while

            if (list.Count > 0)
            {
                return((IStringList[])list.ToArray(typeof(IStringList)));
            }
            else
            {
                return(null);
            }
        }