NArrange.Core.ElementFilter.IsMatch C# (CSharp) Method

IsMatch() public method

Determines whether or not the specified code element matches the filter criteria.
public IsMatch ( ICodeElement codeElement ) : bool
codeElement ICodeElement Code element to analyze.
return bool
        public bool IsMatch(ICodeElement codeElement)
        {
            bool isMatch = false;

            if (codeElement != null)
            {
                isMatch = ConditionExpressionEvaluator.Instance.Evaluate(_conditionExpression, codeElement);
            }

            return isMatch;
        }

Usage Example

        public void IsMatchNameTest()
        {
            ElementFilter filter = new ElementFilter("$(Name) : 'Style'");

            //
            // Not a match
            //
            FieldElement noMatch = new FieldElement();
            noMatch.Name = "Test";
            Assert.IsFalse(filter.IsMatch(noMatch), "IsMatch did not return the expected value.");

            //
            // Match
            //
            FieldElement match = new FieldElement();
            match.Name = "Style";
            Assert.IsTrue(filter.IsMatch(match), "IsMatch did not return the expected value.");
            match.Name = "ElementStyle";
            Assert.IsTrue(filter.IsMatch(match), "IsMatch did not return the expected value.");
            match.Name = "StyleElement";
            Assert.IsTrue(filter.IsMatch(match), "IsMatch did not return the expected value.");

            //
            // Null
            //
            Assert.IsFalse(filter.IsMatch(null), "IsMatch did not return the expected value.");
        }
All Usage Examples Of NArrange.Core.ElementFilter::IsMatch