예제 #1
0
파일: Program.cs 프로젝트: hatahet/antobot
 private static IEnumerable<XElement> getSwearStatsXml(SwearingStats sstats)
 {
     return new XElement[]
     {
         new XElement("totalwords", sstats.totalWords),
         new XElement("swearwords", sstats.swearWords),
         new XElement("popularity",
             sstats.popularity.Select(x => new XElement(x.Key, x.Value)))
     };
 }
예제 #2
0
파일: Program.cs 프로젝트: hatahet/antobot
        private static SwearingStats getSwearStatsFromXml(XElement[] elements)
        {
            XElement twords = elements[0];
            XElement swords = elements[1];
            XElement pop = elements[2];

            int twordsI = int.Parse(twords.Value);
            int swordsI = int.Parse(swords.Value);
            Dictionary<string, int> popularity =
                pop.Elements().ToDictionary(x => x.Name.LocalName, x => int.Parse(x.Value));

            SwearingStats sstats = new SwearingStats();
            sstats.popularity = popularity;
            sstats.swearWords = swordsI;
            sstats.totalWords = twordsI;

            return sstats;
        }