Example #1
0
        /// <summary>
        /// Finds all ExtensionElement based on it's local name
        /// and it's namespace. If namespace is NULL, allwhere
        /// the localname matches is found. If there are extensionelements that do
        /// not implment ExtensionElementFactory, they will not be taken into account
        /// Primary use of this is to find XML nodes
        /// </summary>
        /// <param name="arrList">the array to search through</param>
        /// <param name="localName">the xml local name of the element to find</param>
        /// <param name="ns">the namespace of the elementToPersist</param>
        /// <param name="arr">the array to fill</param>
        /// <returns>none</returns>
        public static ExtensionList FindExtensions(ExtensionList arrList, string localName, string ns, ExtensionList arr)
        {
            if (arrList == null)
            {
                throw new ArgumentNullException("arrList");
            }
            if (arr == null)
            {
                throw new ArgumentNullException("arr");
            }

            foreach (IExtensionElementFactory ob in arrList)
            {
                XmlNode node = ob as XmlNode;
                if (node != null)
                {
                    if (compareXmlNess(node.LocalName, localName, node.NamespaceURI, ns))
                    {
                        arr.Add(ob);
                    }
                }
                else
                {
                    // only if the elements do implement the ExtensionElementFactory
                    // do we know if it's xml name/namespace
                    IExtensionElementFactory ele = ob as IExtensionElementFactory;
                    if (ele != null)
                    {
                        if (compareXmlNess(ele.XmlName, localName, ele.XmlNameSpace, ns))
                        {
                            arr.Add(ob);
                        }
                    }
                }
            }
            return(arr);
        }