예제 #1
0
            /// <summary>
            ///     Create token that matches provided string, string needs to be a single value
            /// </summary>
            /// <param name="tokenString"></param>
            /// <returns></returns>
            /// <exception cref="Exception"></exception>
            public static Token GetMatchingToken(string tokenString)
            {
                if (Equal.TryParse(tokenString, out var token))
                {
                    return(token);
                }
                if (LessThen.TryParse(tokenString, out token))
                {
                    return(token);
                }
                if (LessThenEqual.TryParse(tokenString, out token))
                {
                    return(token);
                }
                if (GreaterThen.TryParse(tokenString, out token))
                {
                    return(token);
                }
                if (GreaterThenEqual.TryParse(tokenString, out token))
                {
                    return(token);
                }
                if (Between.TryParse(tokenString, out token))
                {
                    return(token);
                }

                throw new Exception($"Provided string was invalid {tokenString}, please provide valid range token");
            }