Exemple #1
0
        /// <summary>
        /// Visits the specified element.
        /// </summary>
        /// <param name="element">The element.</param>
        public override void Visit(CompositeBase element)
        {
            if (!element.IsLeaf)
            {
                // process this
                string name = _name;

                if (element.Name != "CALL")
                {
                    if (_name.Length == 0)
                    {
                        _name = element.Name;
                    }
                    else
                    {
                        _name += ":" + element.Name;
                    }
                }
                ProcessNode((Composite)element);
                // and propagate
                foreach (CompositeBase c in (Composite)element)
                {
                    c.Accept(this);
                }
                _name = name;
            }
        }
        /// <summary>
        /// Visits the specified element.
        /// </summary>
        /// <param name="element"></param>
        public override void Visit(CompositeBase element)
        {
            if (Predicate(element))
            {
                _results.Add(element.ParentPathSansRoot());
            }

            base.Visit(element);
        }
Exemple #3
0
 /// <summary>
 /// Visits the specified element.
 /// </summary>
 public virtual void Visit(CompositeBase element)
 {
     // Call this to propagate the tree
     if (!(element is Composite))
     {
         return;
     }
     foreach (CompositeBase c in (Composite)element)
     {
         c.Accept(this);
     }
 }
        /// <summary>
        /// Creates the specified node.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <returns></returns>
        static public CompositeBase CreateCopy(CompositeBase node)
        {
            CompositeBase result;

            if (node.IsLeaf)
            {
                result = new CompositeLeaf((CompositeLeaf)node);
            }
            else
            {
                result = new Composite((Composite)node);                         //BUGBUG N.B. Types are not preserved....
            }
            return(result);
        }
Exemple #5
0
        /// <summary>
        /// populate the Document
        /// </summary>
        /// <param name="element">The element.</param>
        public override void Visit(CompositeBase element)
        {
            bool isRoot = false;

            if (null == _currentNode)
            {
                var rootDescription = new StringBuilder();

                rootDescription.Append("<?xml version='1.0'?>");
                rootDescription.Append("<");
                rootDescription.Append(element.Name);
                rootDescription.Append("/>");

                _document.LoadXml(rootDescription.ToString());
                _currentNode = _document.DocumentElement;
                isRoot       = true;
            }
            if (element.IsLeaf)
            {
                if (_currentNode != null)
                {
                    _currentNode.AppendChild(_document.CreateNode(XmlNodeType.Element, element.Name, element.Value));
                }
            }
            else
            {
                XmlNode oNode;

                if (!isRoot)
                {
                    oNode = _document.CreateNode(XmlNodeType.Element, element.Name, element.Value);
                    _currentNode.AppendChild(oNode);
                }
                else
                {
                    oNode = _currentNode;
                }
                foreach (CompositeBase c in (Composite)element)
                {
                    _currentNode = oNode;
                    c.Accept(this);
                }
            }
        }
 public override void Visit(CompositeBase element)
 {
     if (element.IsLeaf)
     {
         if (_items.ContainsKey(element.Name))
         {
             throw new ApplicationException(string.Format("NodeNameValueVisitor duplicate name error adding {0}/{1}",
                                                          element.ParentPath(), element.Name));
         }
         _items.Add(element.Name, element.Value);
     }
     else
     {
         foreach (CompositeBase c in (Composite)element)
         {
             if (c.IsLeaf)
             {
                 c.Accept(this);
             }
         }
     }
 }
        /// <summary>
        /// Visits the specified element.
        /// </summary>
        /// <param name="element">The element.</param>
        public override void Visit(CompositeBase element)
        {
            if (element.IsLeaf)
            {
                // process this
                var name = element.ParentPath();
                // we want the root node to be implicit
                // this is for CALL roots only should be
                // subclassed to the FnsDomain?
                if (name.StartsWith("CALL:"))
                {
                    name = name.Remove(0, 5);
                }

                _collection.Add(name, element.Value);
            }
            else
            {
                foreach (CompositeBase c in (Composite)element)
                {
                    c.Accept(this);
                }
            }
        }
 /// <summary>
 /// tests the Element method determines inclusion in the results set.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <returns></returns>
 protected virtual bool ElementTest(CompositeBase element)
 {
     return(true);
 }