コード例 #1
0
ファイル: MoonParser.cs プロジェクト: lovelydb/release
        private static MoonSite ParseSite()
        {
            string name = NextLine().Trim();

            if (!name.ToLower().StartsWith("site:"))
            {
                Console.WriteLine("expected 'site:' but got {0}", name);
            }

            name = name.Substring(5).Trim();


            string url = NextLine().Trim();

            if (!url.ToLower().StartsWith("url:"))
            {
                Console.WriteLine("expected 'url:' but got {0}", url);
            }
            url = url.Substring(4).Trim();

            string line = NextLine().Trim();

            if (!line.ToLower().StartsWith("rating:"))
            {
                Console.WriteLine("expected 'rating:' but got {0}", line);
            }
            line = line.Substring(7);


            //Console.WriteLine(line);
            try {
                int rating = Convert.ToInt32(line.Trim());


                //Console.WriteLine("creating new MoonSite");

                MoonSite newsite = new MoonSite(name, url, rating);

                while (PeekLine().Trim().StartsWith("*"))
                {
                    newsite.Issues.Add(ParseIssue());
                }
                return(newsite);
            }
            catch (Exception ex) {
                return(null);
            }
        }
コード例 #2
0
ファイル: MoonParser.cs プロジェクト: akoeplinger/release
        private static MoonSite ParseSite()
        {
            string name = NextLine().Trim();
                        if (!name.ToLower().StartsWith("site:"))
                        {
                                Console.WriteLine("expected 'site:' but got {0}",name);
                        }

                        name = name.Substring(5).Trim();

                        string url = NextLine().Trim();
                        if (!url.ToLower().StartsWith("url:"))
                        {
                                Console.WriteLine("expected 'url:' but got {0}",url);
                        }
                        url = url.Substring(4).Trim();

                        string line = NextLine().Trim();
                        if (!line.ToLower().StartsWith("rating:"))
                        {
                                Console.WriteLine("expected 'rating:' but got {0}",line);
                        }
                        line = line.Substring(7);

                        //Console.WriteLine(line);
                        try {
                            int rating = Convert.ToInt32(line.Trim());

                        //Console.WriteLine("creating new MoonSite");

                MoonSite newsite = new MoonSite(name,url,rating);

                            while(PeekLine().Trim().StartsWith("*"))
                            {
                                    newsite.Issues.Add(ParseIssue());
                            }
                return newsite;
                        }
                        catch(Exception ex) {
                            return null;
                        }
        }