示例#1
0
        public static QueryToken Parse(string tokenString, QueryDescription qd, SubTokensOptions options)
        {
            if (string.IsNullOrEmpty(tokenString))
            {
                throw new ArgumentNullException(nameof(tokenString));
            }

            //https://stackoverflow.com/questions/35418597/split-string-on-the-dot-characters-that-are-not-inside-of-brackets
            string[] parts = Regex.Split(tokenString, @"\.(?!([^[]*\]|[^(]*\)))");

            string firstPart = parts.FirstEx();

            QueryToken result = SubToken(null, qd, options, firstPart);

            if (result == null)
            {
                throw new FormatException("Column {0} not found on query {1}".FormatWith(firstPart, QueryUtils.GetKey(qd.QueryName)));
            }

            foreach (var part in parts.Skip(1))
            {
                var newResult = SubToken(result, qd, options, part);
                result = newResult ?? throw new FormatException("Token with key '{0}' not found on {1} of query {2}".FormatWith(part, result.FullKey(), QueryUtils.GetKey(qd.QueryName)));
            }

            return(result);
        }
示例#2
0
        public static QueryToken Parse(string tokenString, QueryDescription qd, SubTokensOptions options)
        {
            if (string.IsNullOrEmpty(tokenString))
            {
                throw new ArgumentNullException("tokenString");
            }

            string[] parts = tokenString.Split('.');

            string firstPart = parts.FirstEx();

            QueryToken result = SubToken(null, qd, options, firstPart);

            if (result == null)
            {
                throw new FormatException("Column {0} not found on query {1}".FormatWith(firstPart, QueryUtils.GetCleanName(qd.QueryName)));
            }

            foreach (var part in parts.Skip(1))
            {
                var newResult = SubToken(result, qd, options, part);

                if (newResult == null)
                {
                    throw new FormatException("Token with key '{0}' not found on {1} of query {2}".FormatWith(part, result.FullKey(), QueryUtils.GetCleanName(qd.QueryName)));
                }

                result = newResult;
            }

            return(result);
        }
示例#3
0
 public override string ToString()
 {
     return("{0} {1}".FormatWith(token.FullKey(), orderType));
 }