Exemplo n.º 1
0
 /// <summary>
 /// Reads a token and checks it is what is expected.
 /// </summary>
 /// <param name="expectedToken">The expected token.</param>
 internal void ReadToken(string expectedToken)
 {
     base.NextToken();
     if (base.GetStringValue() != expectedToken)
     {
         throw new Exception(string.Format(NumberFormatter.GetNfi(), "Expecting ('{3}') but got a '{0}' at line {1} column {2}.", new object[] { base.GetStringValue(), base.LineNumber, base.Column, expectedToken }));
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// If the current token is a number, this field contains the value of that number.
        /// </summary>
        /// <remarks>
        /// If the current token is a number, this field contains the value of that number. The current token is a number when the value of the ttype field is TT_NUMBER.
        /// </remarks>
        /// <exception cref="T:System.FormatException">Current token is not a number in a valid format.</exception>
        public double GetNumericValue()
        {
            string stringValue = this.GetStringValue();

            if (this.GetTokenType() != Topology.Converters.WellKnownText.TokenType.Number)
            {
                throw new Exception(string.Format(NumberFormatter.GetNfi(), "The token '{0}' is not a number at line {1} column {2}.", new object[] { stringValue, this.LineNumber, this.Column }));
            }
            return(double.Parse(stringValue, NumberFormatter.GetNfi()));
        }