Exemplo n.º 1
0
        public IEnumerable <SearchItem> WhereMainThread(SearchExpressionContext context, IEnumerable <SearchItem> dataSet, string queryStr)
        {
            m_Context = context;
            var query = Parse(queryStr, true);

            if (query.errors.Count != 0)
            {
                foreach (var queryError in query.errors)
                {
                    Debug.LogFormat(LogType.Error, LogOption.NoStacktrace, null, $"Error parsing input at {queryError.index}: {queryError.reason}");
                }

                var errorStr = string.Join("\n", query.errors.Select(err => $"Error parsing input at {err.index}: {err.reason}"));
                context.ThrowError(errorStr);
            }

            var results = TaskEvaluatorManager.EvaluateMainThread(dataSet, item =>
            {
                if (query.Test(item))
                {
                    return(item);
                }
                return(null);
            }, 25);

            m_Context = default;
            return(results);
        }
Exemplo n.º 2
0
        public IEnumerable <SearchItem> Where(SearchExpressionContext context, IEnumerable <SearchItem> dataSet, string queryStr)
        {
            m_Context = context;
            var query = Parse(queryStr, true);

            if (query.errors.Count != 0)
            {
                foreach (var queryError in query.errors)
                {
                    Debug.LogFormat(LogType.Error, LogOption.NoStacktrace, null, $"Error parsing input at {queryError.index}: {queryError.reason}");
                }

                var errorStr = string.Join("\n", query.errors.Select(err => $"Error parsing input at {err.index}: {err.reason}"));
                context.ThrowError(errorStr);
            }

            foreach (var item in dataSet)
            {
                if (item != null)
                {
                    if (query.Test(item))
                    {
                        yield return(item);
                    }
                }
                else
                {
                    yield return(null);
                }
            }
            m_Context = default;
        }