Beispiel #1
0
        /// <summary>
        /// Parse query tree to build list of predicates, with which the search will be made
        /// </summary>
        /// <returns>Search predicates</returns>
        public override IQueryPredicate GetPredicate()
        {
            DomNodePropertyPredicate predicate = new DomNodePropertyPredicate();

            this.BuildPredicate(predicate);
            return(predicate);
        }
Beispiel #2
0
        /// <summary>
        /// Adds a search for DomNode property values with a matching number</summary>
        /// <param name="predicate">Predicate to which the property search expression will be added</param>
        /// <exception cref="ArgumentException">DomNode-specific query tree has been passed an unhandled type of predicate info</exception>
        public override void BuildPredicate(IQueryPredicate predicate)
        {
            // No predicate added if the text input can't be parsed as a number
            Double num;

            if (Double.TryParse(TextInput1, out num) == false)
            {
                return;
            }

            DomNodePropertyPredicate domNodePredicate = (DomNodePropertyPredicate)predicate;

            if (domNodePredicate == null)
            {
                throw new ArgumentException("DomNode-specific query tree has been passed an unhandled type of predicate info");
            }

            // Add appropriate search expression to predicate
            switch (SelectedItem.Tag)
            {
            case (UInt64)NumericalQuery.Equals:
                domNodePredicate.AddNumberValueEqualsExpression(num, m_isReplacePattern);
                break;

            case (UInt64)NumericalQuery.Lesser:
                domNodePredicate.AddNumberValueLesserExpression(num, m_isReplacePattern);
                break;

            case (UInt64)NumericalQuery.LesserEqual:
                domNodePredicate.AddNumberValueLesserEqualExpression(num, m_isReplacePattern);
                break;

            case (UInt64)NumericalQuery.GreaterEqual:
                domNodePredicate.AddNumberValueGreaterEqualExpression(num, m_isReplacePattern);
                break;

            case (UInt64)NumericalQuery.Greater:
                domNodePredicate.AddNumberValueGreaterExpression(num, m_isReplacePattern);
                break;

            case (UInt64)NumericalQuery.Between:
            {
                Double num2;
                if (Double.TryParse(TextInput2, out num2))
                {
                    domNodePredicate.AddNumberValueBetweenExpression(num, num2, m_isReplacePattern);
                }
                break;
            }

            default:
                // throw exception...?
                break;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Adds a search for DomNode property values with a matching string</summary>
        /// <param name="predicate">Predicate to which the property search expression will be added</param>
        /// <exception cref="ArgumentException">DomNode-specific query tree has been passed an unhandled type of predicate info</exception>
        public override void BuildPredicate(IQueryPredicate predicate)
        {
            DomNodePropertyPredicate domNodePropertyPredicate = (DomNodePropertyPredicate)predicate;

            if (domNodePropertyPredicate == null)
            {
                throw new ArgumentException("DomNode-specific query tree has been passed an unhandled type of predicate info");
            }

            BuildStringPredicate(domNodePropertyPredicate, DomNodeQuery.PropertySearchTarget.Value);
        }
Beispiel #4
0
        public static IQueryPredicate CreateSearchPredicate(Bookmark bkmrk, Uri baseUri)
        {
            // note -- we will only compare the "model"
            var predicate = new Sce.Atf.Dom.DomNodePropertyPredicate();

            predicate.AddPropertyNameExpression("Model");
            var searchName = Path.GetFileNameWithoutExtension(bkmrk.Model.LocalPath);

            predicate.AddValueStringSearchExpression(searchName, (UInt64)StringQuery.Matches, false);
            return(predicate);
        }
Beispiel #5
0
        public static IQueryPredicate CreateSearchPredicate(Uri modelName)
        {
            // we need to build a predicate that looks for placements that are using this model
            var predicate = new Sce.Atf.Dom.DomNodePropertyPredicate();

            predicate.AddPropertyNameExpression("Model");
            var searchName = Path.GetFileNameWithoutExtension(modelName.LocalPath);

            predicate.AddValueStringSearchExpression(searchName, (UInt64)StringQuery.Contains, false);
            return(predicate);
        }
Beispiel #6
0
        /// <summary>
        /// Adds a search for DomNode properties with name "Name", and with a matching string value</summary>
        /// <param name="predicate">Predicate to which the property search expression will be added</param>
        /// <exception cref="ArgumentException">DomNode-specific query tree has been passed an unhandled type of predicate info</exception>
        public override void BuildPredicate(IQueryPredicate predicate)
        {
            DomNodePropertyPredicate domNodePredicate = (DomNodePropertyPredicate)predicate;

            if (domNodePredicate == null)
            {
                throw new ArgumentException("DomNode-specific query tree has been passed an unhandled type of predicate info");
            }

            domNodePredicate.AddPropertyNameExpression("Name");
            base.BuildPredicate(domNodePredicate);
        }
Beispiel #7
0
        /// <summary>
        /// Adds a search for DomNode property names or values with a matching string</summary>
        /// <param name="predicate">Predicate to which the property search expression will be added</param>
        /// <param name="target">Whether search is on DomNode property names, or property values</param>
        /// <exception cref="InvalidOperationException">Unhandled property search target type</exception>
        protected void BuildStringPredicate(DomNodePropertyPredicate predicate, DomNodeQuery.PropertySearchTarget target)
        {
            switch (target)
            {
            case DomNodeQuery.PropertySearchTarget.Name:
                predicate.AddNameStringSearchExpression(TextInput, SelectedItem.Tag, m_isReplacePattern);
                break;

            case DomNodeQuery.PropertySearchTarget.Value:
                predicate.AddValueStringSearchExpression(TextInput, SelectedItem.Tag, m_isReplacePattern);
                break;

            default:
                throw new InvalidOperationException("Unhandled property search target type");
            }
        }