예제 #1
0
 private static IEnumerable <RomInfo> GetEntries(XDocument xmlDat, string platformId)
 {
     return(from game in xmlDat.Root.Elements("game").AsParallel()
            from rom in game.Elements("rom").AsParallel()
            where rom.Attribute("size").Value != "0"
            let crc = rom.Attribute("crc").Value.ToUpperInvariant()
                      let md5 = rom.Attribute("md5").Value.ToUpperInvariant()
                                let sha1 = rom.Attribute("sha1").Value.ToUpperInvariant()
                                           let filename = rom.Attribute("name").Value
                                                          let region = RegionParser.ParseRegion(filename)
                                                                       let mimetype = DatParser.GetMimeType(filename, platformId)
                                                                                      where mimetype != null
                                                                                      select new RomInfo(platformId, crc, md5, sha1, region, mimetype, filename));
 }
예제 #2
0
        private static IEnumerable <RomInfo> GetEntries(MatchCollection cmpMatches, string platformId)
        {
            const string regex = @"(?:\s|)(.*?)(?:\sname|\scrc|\scrc32|\smd5|\ssha1|\sbaddump|\snodump|\ssize|$)";

            return(from Match romEntry in cmpMatches.AsParallel()
                   let match = romEntry.Value
                               let filename = Regex.Match(match, "name" + regex).Groups[1].Value.Trim('"')
                                              let crc = Regex.Match(match, "crc" + regex).Groups[1].Value
                                                        let md5 = Regex.Match(match, "md5" + regex).Groups[1].Value
                                                                  let sha1 = Regex.Match(match, "sha1" + regex).Groups[1].Value
                                                                             let region = RegionParser.ParseRegion(filename)
                                                                                          let mimetype = DatParser.GetMimeType(filename, platformId)
                                                                                                         where mimetype != null
                                                                                                         select new RomInfo(platformId, crc, md5, sha1, region, mimetype, filename));
        }