Example #1
0
        IList <XPathObjectNode> ActivateDictionary()
        {
            // no attributes
            _attributes = _emptyAttributes;

            // collect elements
            var elements = new List <XPathObjectNode>();

            foreach (DictionaryEntry entry in (IDictionary)_target)
            {
                if (entry.Value == null)
                {
                    continue;
                }

                var node = new XPathObjectNode(_context, entry.Value, null, this, elements, elements.Count);

                elements.Add(node);

                node.AddSpecialName("key", entry.Key.ToString());
            }

            if (elements.Count == 0)
            {
                _elements.Target = _emptyElements;
            }
            else
            {
                _elements.Target = elements;
            }

            return(elements);
        }
Example #2
0
        ///
        internal XPathObjectNavigator(object root, XPathObjectContext context)
        {
            if (root == null)
            {
                throw new ArgumentNullException("root");
            }

            _context = context ?? throw new ArgumentNullException("context");
            _root    = new XPathObjectNode(context, root);

            //???? fails without it
            var type = root.GetType();
            var name = type.FullName;

            if (type.IsGenericType)
            {
                name = name.Remove(name.IndexOf('`'));
            }
            _root.AddSpecialName("type", name);
        }