private CategoryDirectory ReadResult(System.Xml.XmlReader reader, bool securityTrimmingEnabled)
        {
            CategoryDirectory result = null;
            if (reader.NodeType == System.Xml.XmlNodeType.Element)
            {
                if (reader.LocalName == "category" && reader.NamespaceURI == ns)
                {
                    if (DeterminVisible(reader) && DeterminSecure(securityTrimmingEnabled, reader))
                    {
                        result = new CategoryDirectory();
                        if (reader.MoveToAttribute("name"))
                            result.Name = reader.Value;

                        if (reader.MoveToAttribute("title"))
                            result.Title = reader.Value;

                        reader.MoveToElement();
                    }

                }
                else if (reader.LocalName == "item" && reader.NamespaceURI == ns)
                {
                    if (DeterminVisible(reader) && DeterminSecure(securityTrimmingEnabled, reader))
                    {
                        result = new CategoryLink();
                        if (reader.MoveToAttribute("name"))
                            result.Name = reader.Value;
                        if (reader.MoveToAttribute("title"))
                            result.Title = reader.Value;
                        if (reader.MoveToAttribute("group"))
                            ((CategoryLink)result).Group = reader.ReadContentAsInt();
                        if (reader.MoveToAttribute("href"))
                            ((CategoryLink)result).Url = reader.Value;
                        if (reader.MoveToAttribute("role"))
                            ((CategoryLink)result).Role = reader.Value;
                        if (reader.MoveToAttribute("feature"))
                            ((CategoryLink)result).Feature = reader.Value;
                    }
                }
                else if (reader.LocalName == "group" && reader.NamespaceURI == ns)
                {
                    if (DeterminVisible(reader) && DeterminSecure(securityTrimmingEnabled, reader))
                    {
                        result = new CategoryGroup();
                        if (reader.MoveToAttribute("name"))
                            result.Name = reader.Value;
                        if (reader.MoveToAttribute("title"))
                            result.Title = reader.Value;
                        reader.MoveToElement();
                        ArrayList list = new ArrayList();

                        ReadSubItems(reader, list, securityTrimmingEnabled);
                        ((CategoryGroup)result).Categories = (CategoryDirectory[])list.ToArray(typeof(CategoryDirectory));
                    }
                    else
                    {
                        var level = reader.Depth;
                        while (reader.Read() && reader.Depth > level)
                        {
                            reader.Skip(); //跳过其任何子节点
                        }
                    }
                }
            }

            reader.MoveToElement();

            return result;
        }
Esempio n. 2
0
        private CategoryDirectory ReadResult(System.Xml.XmlReader reader, bool securityTrimmingEnabled)
        {
            CategoryDirectory result = null;

            if (reader.NodeType == System.Xml.XmlNodeType.Element)
            {
                if (reader.LocalName == "category" && reader.NamespaceURI == ns)
                {
                    if (DeterminVisible(reader) && DeterminSecure(securityTrimmingEnabled, reader))
                    {
                        result = new CategoryDirectory();
                        if (reader.MoveToAttribute("name"))
                        {
                            result.Name = reader.Value;
                        }

                        if (reader.MoveToAttribute("title"))
                        {
                            result.Title = reader.Value;
                        }

                        reader.MoveToElement();
                    }
                }
                else if (reader.LocalName == "item" && reader.NamespaceURI == ns)
                {
                    if (DeterminVisible(reader) && DeterminSecure(securityTrimmingEnabled, reader))
                    {
                        result = new CategoryLink();
                        if (reader.MoveToAttribute("name"))
                        {
                            result.Name = reader.Value;
                        }
                        if (reader.MoveToAttribute("title"))
                        {
                            result.Title = reader.Value;
                        }
                        if (reader.MoveToAttribute("group"))
                        {
                            ((CategoryLink)result).Group = reader.ReadContentAsInt();
                        }
                        if (reader.MoveToAttribute("href"))
                        {
                            ((CategoryLink)result).Url = reader.Value;
                        }
                        if (reader.MoveToAttribute("role"))
                        {
                            ((CategoryLink)result).Role = reader.Value;
                        }
                        if (reader.MoveToAttribute("feature"))
                        {
                            ((CategoryLink)result).Feature = reader.Value;
                        }
                    }
                }
                else if (reader.LocalName == "group" && reader.NamespaceURI == ns)
                {
                    if (DeterminVisible(reader) && DeterminSecure(securityTrimmingEnabled, reader))
                    {
                        result = new CategoryGroup();
                        if (reader.MoveToAttribute("name"))
                        {
                            result.Name = reader.Value;
                        }
                        if (reader.MoveToAttribute("title"))
                        {
                            result.Title = reader.Value;
                        }
                        reader.MoveToElement();
                        ArrayList list = new ArrayList();

                        ReadSubItems(reader, list, securityTrimmingEnabled);
                        ((CategoryGroup)result).Categories = (CategoryDirectory[])list.ToArray(typeof(CategoryDirectory));
                    }
                    else
                    {
                        var level = reader.Depth;
                        while (reader.Read() && reader.Depth > level)
                        {
                            reader.Skip(); //跳过其任何子节点
                        }
                    }
                }
            }

            reader.MoveToElement();

            return(result);
        }