GetKey() публичный статический Метод

public static GetKey ( object queryName ) : string
queryName object
Результат string
Пример #1
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.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(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);
        }
Пример #3
0
        public QueryToken SubTokenInternal(string key, SubTokensOptions options)
        {
            var result = CachedSubTokensOverride(options).TryGetC(key) ?? OnEntityExtension(this).SingleOrDefaultEx(a => a.Key == key);

            if (result == null)
            {
                return(null);
            }

            string allowed = result.IsAllowed();

            if (allowed != null)
            {
                throw new UnauthorizedAccessException($"Access to token '{key}' in '{this.FullKey()}' for query '{QueryUtils.GetKey(this.QueryName)}' is not allowed because: {allowed}");
            }

            return(result);
        }