private static int GetAddress(string file, RomVersion version, string addrVar) { var gFile = from a in addresses.Games where a.Name == version.Game.ToString() select a; var aFile = from b in gFile.Single().Files where b.Filename == file select b; var iAddr = from c in aFile.Single().Items where c.Variable == addrVar select c; var qualAddr = from d in iAddr.Single().Values where d.Version == version.ToString() select d; int?address = qualAddr.Single().Address; if (address == null) { throw new ArgumentException(String.Format("{1} does not exist under {0} in Addresses.xml", file, addrVar)); } return((int)address); }
private static bool TryGetAddrValue(Addr2.Address addr, RomVersion version, out int result) { try { result = Convert.ToInt32(addr.Data.Single(x => x.ver == version.ToString()).Value, 16); } catch { result = -1; return(false); } return(true); }