Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ToXPathDouble()

static double System.Xml.XmlConvert.ToXPathDouble ( object o)
inlinestaticpackage

Definition at line 943 of file XmlConvert.cs.

944 {
945 if (o is string value)
946 {
947 string text = TrimString(value);
948 if (text.Length != 0 && text[0] != '+' && double.TryParse(text, NumberStyles.AllowTrailingWhite | NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint, NumberFormatInfo.InvariantInfo, out var result))
949 {
950 return result;
951 }
952 return double.NaN;
953 }
954 if (o is double)
955 {
956 return (double)o;
957 }
958 if (o is bool)
959 {
960 if (!(bool)o)
961 {
962 return 0.0;
963 }
964 return 1.0;
965 }
966 try
967 {
968 return Convert.ToDouble(o, NumberFormatInfo.InvariantInfo);
969 }
970 catch (FormatException)
971 {
972 }
973 catch (OverflowException)
974 {
975 }
976 catch (ArgumentNullException)
977 {
978 }
979 return double.NaN;
980 }
static string TrimString(string value)

References System.Xml.Dictionary, System.Globalization.NumberFormatInfo.InvariantInfo, System.text, System.Convert.ToDouble(), System.Xml.XmlConvert.TrimString(), and System.value.

Referenced by MS.Internal.Xml.XPath.XPathComparerHelper.Compare(), System.Xml.Xsl.XsltOld.TemplateAction.CompileAttribute(), System.Xml.Xsl.XsltOld.ContainerAction.CompileStylesheetAttributes(), MS.Internal.Xml.XPath.NumericExpr.Evaluate(), System.Xml.Xsl.XsltOld.NumberAction.NumberingFormat.FormatItem(), System.Xml.Xsl.XsltOld.Processor.GetGlobalParameter(), MS.Internal.Xml.XPath.NumberFunctions.Number(), MS.Internal.Xml.XPath.NumberFunctions.Number(), MS.Internal.Xml.XPath.NumberFunctions.Round(), MS.Internal.Xml.XPath.XPathScanner.ScanFraction(), MS.Internal.Xml.XPath.XPathScanner.ScanNumber(), MS.Internal.Xml.XPath.StringFunctions.Substring(), and System.Xml.Xsl.XsltOld.XsltCompileContext.XsltFunctionImpl.ToNumber().