Esempio n. 1
0
        /// <summary>Removes the given element from any attribute caches. You must check AttributesCached first.</summary>
        public void RemoveCachedElement(Element ele)
        {
            List <string> toRemove = null;

            foreach (KeyValuePair <string, AttributeLookup> kvp in AttributeIndex)
            {
                string          attribute = kvp.Key;
                AttributeLookup lookup    = kvp.Value;

                // Got this attribute?
                string value = ele[attribute];

                if (value == null)
                {
                    continue;
                }

                // Remove it:
                if (lookup.Remove(value, ele))
                {
                    // Remove the lookup too!
                    if (toRemove == null)
                    {
                        toRemove = new List <string>();
                    }

                    toRemove.Add(attribute);
                }
            }

            if (toRemove == null)
            {
                return;
            }

            if (toRemove.Count == AttributeIndex.Count)
            {
                // Remove the whole thing:
                AttributeIndex = null;
                return;
            }

            for (int i = toRemove.Count - 1; i >= 0; i--)
            {
                // Remove from attrib index:
                AttributeIndex.Remove(toRemove[i]);
            }
        }
Esempio n. 2
0
        /// <summary>Starts indexing the given attribute right now.</summary>
        public void StartAttributeIndex(string attrib)
        {
            // Create the lookup:
            AttributeLookup lookup = new AttributeLookup();

            // Index:
            html.AddToAttributeLookup(attrib, lookup);

            if (lookup.Count == 0)
            {
                // Well.. that was pointless! Nothing to actually index!
                return;
            }

            if (AttributeIndex == null)
            {
                // Create the index now:
                AttributeIndex = new Dictionary <string, AttributeLookup>();
            }

            AttributeIndex[attrib] = lookup;
        }
Esempio n. 3
0
        /// <summary>Adds this element to the given attribute lookup.</summary>
        public void AddToAttributeLookup(string attrib, AttributeLookup lookup)
        {
            // Got the attribute?
            string value;

            if (Properties.TryGetValue(attrib, out value))
            {
                lookup.Add(value, this);
            }

            // Any kids got it?
            if (ChildNodes == null)
            {
                return;
            }

            // Add each one..
            for (int i = 0; i < ChildNodes.Count; i++)
            {
                // Add it:
                ChildNodes[i].AddToAttributeLookup(attrib, lookup);
            }
        }
//--------------------------------------
//--------------------------------------