Example #1
0
            public override void WritePropertyName(string name)
            {
                m_reentrancy++;
                base.WritePropertyName(name);
                m_reentrancy--;

                if (m_reentrancy == 0)
                {
                    // pop the previous property off the stack if we aren't the first one
                    if (m_statusStack.Peek().IsProperty)
                    {
                        m_statusStack.Pop();
                    }

                    // check to see if this property has been included, or an ancestor or a descendant
                    Status     status     = m_statusStack.Peek();
                    FilterNode node       = status.Node;
                    FilterNode childNode  = node == null ? null : node.FindChild(name);
                    bool       isIncluded = status.IsIncluded && (node == null || ShouldIncludeProperty(node, childNode));
                    if (isIncluded)
                    {
                        m_writer.WritePropertyName(name);
                    }

                    // push a node for this property onto the stack
                    m_statusStack.Push(new Status {
                        IsIncluded = isIncluded, IsProperty = true, Node = childNode
                    });
                }
            }
Example #2
0
        /// <summary>
        /// Determines if the specified path is included by the filter.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns>True if the specified path is included by the filter.</returns>
        public bool IsPathIncluded(string path)
        {
            PropertyPath propertyPath = PropertyPath.TryParse(path, null);

            if (propertyPath == null || propertyPath.IsExcluded)
            {
                return(false);
            }

            FilterNode node = m_rootNode;

            foreach (string part in propertyPath.Parts)
            {
                FilterNode childNode = node.FindChild(part);
                if (!ShouldIncludeProperty(node, childNode))
                {
                    return(false);
                }
                if (childNode == null)
                {
                    break;
                }
                node = childNode;
            }

            return(true);
        }