internal static int ParseHexInt(string strToParse, XObject xObj)
{
const string HexPrefix = "0x";
// Prefix "0x" required in RomRaider-format
// but not allowed in int.Parse(...) even though using NumberStyles.HexNumber.
int index0x = strToParse.IndexOf (HexPrefix);
if (index0x < 0) {
string message = "Prefix '" + HexPrefix + "' missing in XML item: " + xObj.ToString ();
ThrowXmlExceptionWithLineInfo (message, null, xObj);
}
try {
return int.Parse (strToParse.Substring (index0x + HexPrefix.Length), System.Globalization.NumberStyles.HexNumber, NumberFormatInfoInvariant);
} catch (Exception ex) {
ThrowParse (ex, xObj, "hex integer");
throw;
}
}