Exemplo n.º 1
0
        private SearchExpressionNode LoadNodeData(SearchExpressionNode node, IDictionary info)
        {
            if (SJSON.TryGetValue(info, ExpressionField.name, out var name))
            {
                node.name = Convert.ToString(name);
            }

            if (SJSON.TryGetValue(info, ExpressionField.value, out var value))
            {
                node.value = value;
            }

            if (node.type == ExpressionType.Expression)
            {
                var nestedExpression = new SearchExpression(m_SearchOptions);

                if (node.value is string expressionPath && File.Exists(expressionPath))
                {
                    nestedExpression.Load(expressionPath);
                }
                else if (SJSON.TryGetValue(info, ExpressionField.source, out var source) && source is IDictionary sourceData)
                {
                    nestedExpression.Load(sourceData);
                }

                if (nestedExpression.m_EvalNode != null && nestedExpression.m_EvalNode.source != null)
                {
                    node.source = nestedExpression.m_EvalNode.source;
                }
            }
Exemplo n.º 2
0
        /// <summary>
        /// Load a search expression asset.
        /// </summary>
        /// <param name="expressionPath">Asset path of the search expression</param>
        /// <param name="options">Options defining how the query will be performed</param>
        /// <returns>Returns a SearchExpression ready to be evaluated.</returns>
        public static ISearchExpression LoadExpression(string expressionPath, SearchFlags options = SearchFlags.Default)
        {
            if (!File.Exists(expressionPath))
            {
                throw new ArgumentException($"Cannot find expression {expressionPath}", nameof(expressionPath));
            }

            var se = new SearchExpression(options);

            se.Load(expressionPath);
            return(se);
        }
Exemplo n.º 3
0
        private void Reload()
        {
            if (!IsCurrentExpressionPathValid())
            {
                return;
            }

            m_Expression.Reset();
            m_Expression.Load(m_ExpressionPath);
            m_ExpressionGraph.Reload();

            UpdateDocumentInfo();
        }
Exemplo n.º 4
0
        private void InitializeExpression()
        {
            if (m_Expression != null)
            {
                return;
            }

            m_ExpressionPath  = AssetDatabase.GetAssetPath(target);
            m_ExpressionName  = Path.GetFileNameWithoutExtension(m_ExpressionPath);
            m_ExpressionTitle = new GUIContent(m_ExpressionName, Icons.quicksearch, m_ExpressionPath);

            m_Expression = new SearchExpression(SearchSettings.GetContextOptions());
            m_Expression.Load(m_ExpressionPath);
            m_Expression.Evaluate();
        }