Ejemplo n.º 1
0
        protected SiteMapBase()
        {
            CacheDurationInMinutes = DefaultCacheDurationInMinutes;
            Compress = DefaultCompress;
            GenerateSearchEngineMap = DefaultGenerateSearchEngineMap;

            RootNode = new SiteMapNode();
        }
Ejemplo n.º 2
0
        public SiteMapNodeBuilder Add()
        {
            var node = new SiteMapNode();

            parent.ChildNodes.Add(node);

            return new SiteMapNodeBuilder(node);
        }
Ejemplo n.º 3
0
        public virtual void Reset()
        {
            CacheDurationInMinutes = DefaultCacheDurationInMinutes;
            Compress = DefaultCompress;
            GenerateSearchEngineMap = DefaultGenerateSearchEngineMap;

            RootNode = new SiteMapNode();
        }
Ejemplo n.º 4
0
        public SiteMapNodeFactory(SiteMapNode parent)
        {
            Check.Argument.IsNotNull(parent, "parent");

            this.parent = parent;
        }
Ejemplo n.º 5
0
        private static void PopulateNode(SiteMapNode siteMapNode, XmlNode xmlNode)
        {
            var routeValues = new RouteValueDictionary();

            XmlNode xmlRouteValuesNode = xmlNode.FirstChild;

            if ((xmlRouteValuesNode != null) && xmlRouteValuesNode.LocalName.IsCaseSensitiveEqual(RouteValuesNodeName))
            {
                foreach (XmlNode routeValue in xmlRouteValuesNode.ChildNodes)
                {
                    routeValues[routeValue.LocalName] = routeValue.InnerText;
                }
            }

            siteMapNode.Title = GetStringValueFromAttribute(xmlNode, TitleAttributeName);
            siteMapNode.Visible = GetBooleanValueFromAttribute(xmlNode, VisibleAttributeName, true);

            string routeName = GetStringValueFromAttribute(xmlNode, RouteAttributeName);
            string controllerName = GetStringValueFromAttribute(xmlNode, ControllerAttributeName);
            string actionName = GetStringValueFromAttribute(xmlNode, ActionAttributeName);
            string url = GetStringValueFromAttribute(xmlNode, UrlAttributeName);

            string areaName = GetStringValueFromAttribute(xmlNode, AreaAttributeName);

            if (areaName != null)
            {
                routeValues["area"] = areaName;
            }

            if (!string.IsNullOrEmpty(routeName))
            {
                siteMapNode.RouteName = routeName;
                siteMapNode.RouteValues.Clear();
                siteMapNode.RouteValues.Merge(routeValues);
            }
            else if (!string.IsNullOrEmpty(controllerName) && !string.IsNullOrEmpty(actionName))
            {
                siteMapNode.ControllerName = controllerName;
                siteMapNode.ActionName = actionName;
                siteMapNode.RouteValues.Clear();
                siteMapNode.RouteValues.Merge(routeValues);
            }
            else if (!string.IsNullOrEmpty(url))
            {
                siteMapNode.Url = url;
            }

            DateTime? lastModified = GetDateValueFromAttribute(xmlNode, LastModifiedAttributeName);

            if (lastModified.HasValue)
            {
                siteMapNode.LastModifiedAt = lastModified.Value;
            }

            siteMapNode.IncludeInSearchEngineIndex = GetBooleanValueFromAttribute(xmlNode, IncludeInSearchEngineIndexAttributeName, true);

            if (xmlNode.Attributes != null)
                foreach (XmlAttribute attribute in xmlNode.Attributes)
                {
                    if (!string.IsNullOrEmpty(attribute.LocalName))
                    {
                        // Only add unknown attibutes
                        if (Array.BinarySearch(knownAttributes, attribute.LocalName, StringComparer.OrdinalIgnoreCase) < 0)
                        {
                            siteMapNode.Attributes.Add(attribute.LocalName, attribute.Value);
                        }
                    }
                }
        }
Ejemplo n.º 6
0
        private static void Iterate(SiteMapNode siteMapNode, XmlNode xmlNode)
        {
            PopulateNode(siteMapNode, xmlNode);

            foreach (XmlNode xmlChildNode in xmlNode.ChildNodes)
            {
                if (xmlChildNode.LocalName.IsCaseSensitiveEqual(SiteMapNodeName))
                {
                    var siteMapChildNode = new SiteMapNode();
                    siteMapNode.ChildNodes.Add(siteMapChildNode);

                    Iterate(siteMapChildNode, xmlChildNode);
                }
            }
        }