TryGetDoubleValue() public method

public TryGetDoubleValue ( Token token, double &value ) : bool
token Token
value double
return bool
        static bool TryParseElement(Lexer lexer, out StringWithQualityHeaderValue parsedValue, out Token t)
        {
            parsedValue = null;
            t           = lexer.Scan();
            if (t != Token.Type.Token)
            {
                return(false);
            }

            var value = new StringWithQualityHeaderValue();

            value.Value = lexer.GetStringValue(t);

            t = lexer.Scan();
            if (t == Token.Type.SeparatorSemicolon)
            {
                t = lexer.Scan();
                if (t != Token.Type.Token)
                {
                    return(false);
                }

                var s = lexer.GetStringValue(t);
                if (s != "q" && s != "Q")
                {
                    return(false);
                }

                t = lexer.Scan();
                if (t != Token.Type.SeparatorEqual)
                {
                    return(false);
                }

                t = lexer.Scan();

                double d;
                if (!lexer.TryGetDoubleValue(t, out d))
                {
                    return(false);
                }

                if (d > 1)
                {
                    return(false);
                }

                value.Quality = d;

                t = lexer.Scan();
            }

            parsedValue = value;
            return(true);
        }
		static bool TryParseElement (Lexer lexer, out StringWithQualityHeaderValue parsedValue, out Token t)
		{
			parsedValue = null;
			t = lexer.Scan ();
			if (t != Token.Type.Token)
				return false;

			var value = new StringWithQualityHeaderValue ();
			value.Value = lexer.GetStringValue (t);

			t = lexer.Scan ();
			if (t == Token.Type.SeparatorSemicolon) {
				t = lexer.Scan ();
				if (t != Token.Type.Token)
					return false;

				var s = lexer.GetStringValue (t);
				if (s != "q" && s != "Q")
					return false;

				t = lexer.Scan ();
				if (t != Token.Type.SeparatorEqual)
					return false;

				t = lexer.Scan ();

				double d;
				if (!lexer.TryGetDoubleValue (t, out d))
					return false;

				if (d > 1)
					return false;

				value.Quality = d;

				t = lexer.Scan ();
			}

			parsedValue = value;
			return true;
		}
		public static bool TryParse (string input, out StringWithQualityHeaderValue parsedValue)
		{
			parsedValue = null;

			var lexer = new Lexer (input);
			var t = lexer.Scan ();
			if (t != Token.Type.Token)
				return false;

			var value = new StringWithQualityHeaderValue ();
			value.Value = lexer.GetStringValue (t);

			t = lexer.Scan ();
			if (t == Token.Type.SeparatorSemicolon) {
				t = lexer.Scan ();
				if (t != Token.Type.Token)
					return false;

				var s = lexer.GetStringValue (t);
				if (s != "q" && s != "Q")
					return false;

				t = lexer.Scan ();
				if (t != Token.Type.SeparatorEqual)
					return false;

				t = lexer.Scan ();

				double d;
				if (!lexer.TryGetDoubleValue (t, out d))
					return false;

				if (d > 1)
					return false;

				value.Quality = d;

				t = lexer.Scan ();
			}

			if (t != Token.Type.End)
				return false;

			parsedValue = value;
			return true;
		}