Opc.Ua.XmlDecoder.ReadDouble C# (CSharp) Method

ReadDouble() public method

Reads a double from the stream.
public ReadDouble ( string fieldName ) : double
fieldName string
return double
        public double ReadDouble(string fieldName)
        {
            if (BeginField(fieldName, true))
            {
                string xml = ReadString();

                if (!String.IsNullOrEmpty(xml))
                {
                    double value = 0;

                    if (xml.Length == 3)
                    {
                        if (xml == "NaN")
                        {
                            value = Single.NaN;
                        }

                        if (xml == "INF")
                        {
                            value = Single.PositiveInfinity;
                        }
                    }
                    
                    if (xml.Length == 4)
                    {
                        if (xml == "-INF")
                        {
                            value = Single.NegativeInfinity;
                        }
                    }

                    if (value == 0)
                    {
                        value = XmlConvert.ToDouble(xml);
                    }

                    EndField(fieldName);
                    return value;
                }
            }

            return 0;
        }