IsValidToken() public static method

public static IsValidToken ( string input ) : bool
input string
return bool
        static string EncodeBase64Value(string value)
        {
            bool quoted = value.Length > 1 && value [0] == '"' && value [value.Length - 1] == '"';

            if (quoted)
            {
                value = value.Substring(1, value.Length - 2);
            }

            for (int i = 0; i < value.Length; ++i)
            {
                var ch = value[i];
                if (ch > 127)
                {
                    var encoding = Encoding.UTF8;
                    return(string.Format("\"=?{0}?B?{1}?=\"",
                                         encoding.WebName, Convert.ToBase64String(encoding.GetBytes(value))));
                }
            }

            if (quoted || !Lexer.IsValidToken(value))
            {
                return("\"" + value + "\"");
            }

            return(value);
        }
Beispiel #2
0
            public static bool TryCheck(string s)
            {
                if (s == null)
                {
                    return(false);
                }

                return(Lexer.IsValidToken(s));
            }
Beispiel #3
0
            public static bool TryParse(string input, out string result)
            {
                if (input != null && Lexer.IsValidToken(input))
                {
                    result = input;
                    return(true);
                }

                result = null;
                return(false);
            }
Beispiel #4
0
            public static void Check(string s)
            {
                if (s == null)
                {
                    throw new ArgumentNullException();
                }

                if (!Lexer.IsValidToken(s))
                {
                    if (s.Length == 0)
                    {
                        throw new ArgumentException();
                    }

                    throw new FormatException(s);
                }
            }
Beispiel #5
0
            public static bool TryCheck(string s)
            {
                if (s == null)
                {
                    return(false);
                }

                if (!Lexer.IsValidToken(s))
                {
                    if (s.Length == 0)
                    {
                        return(false);
                    }

                    return(false);
                }

                return(true);
            }
        static string EncodeBase64Value(string value)
        {
            for (int i = 0; i < value.Length; ++i)
            {
                var ch = value[i];
                if (ch > 127)
                {
                    var encoding = Encoding.UTF8;
                    return(string.Format("\"=?{0}?B?{1}?=\"",
                                         encoding.WebName, Convert.ToBase64String(encoding.GetBytes(value))));
                }
            }

            if (!Lexer.IsValidToken(value))
            {
                return("\"" + value + "\"");
            }

            return(value);
        }