Example #1
0
        internal virtual void InternalLoad(string physicalPath)
        {
            string text = CFiles.ReadFile(physicalPath);

            if (!string.IsNullOrEmpty(text))
            {
                using (StringReader stringReader = new StringReader(text))
                {
                    using (XmlReader xmlReader = XmlReader.Create(stringReader, new XmlReaderSettings
                    {
                        CloseInput = true,
                        IgnoreWhitespace = true,
                        IgnoreComments = true,
                        IgnoreProcessingInstructions = true
                    }))
                    {
                        XmlDocument xmlDocument = new XmlDocument();
                        xmlDocument.Load(xmlReader);
                        this.Reset();
                        if (xmlDocument.DocumentElement != null && xmlDocument.HasChildNodes)
                        {
                            base.CacheDurationInMinutes = XmlSiteMap.GetFloatValueFromAttribute(xmlDocument.DocumentElement, "cacheDurationInMinutes", SiteMapBase.DefaultCacheDurationInMinutes);
                            base.Compress = XmlSiteMap.GetBooleanValueFromAttribute(xmlDocument.DocumentElement, "compress", true);
                            base.GenerateSearchEngineMap = XmlSiteMap.GetBooleanValueFromAttribute(xmlDocument.DocumentElement, "generateSearchEngineMap", true);
                            XmlNode firstChild = xmlDocument.DocumentElement.FirstChild;
                            XmlSiteMap.Iterate(base.RootNode, firstChild);
                            this.InsertInCache(physicalPath);
                        }
                    }
                }
            }
        }
Example #2
0
        private static void PopulateNode(SiteMapNode siteMapNode, XmlNode xmlNode)
        {
            RouteValueDictionary routeValueDictionary = new RouteValueDictionary();
            XmlNode firstChild = xmlNode.FirstChild;

            if (firstChild != null && firstChild.LocalName.IsCaseSensitiveEqual("routeValues"))
            {
                foreach (XmlNode xmlNode2 in firstChild.ChildNodes)
                {
                    routeValueDictionary[xmlNode2.LocalName] = xmlNode2.InnerText;
                }
            }
            siteMapNode.Title   = XmlSiteMap.GetStringValueFromAttribute(xmlNode, "title");
            siteMapNode.Visible = XmlSiteMap.GetBooleanValueFromAttribute(xmlNode, "visible", true);
            string stringValueFromAttribute  = XmlSiteMap.GetStringValueFromAttribute(xmlNode, "route");
            string stringValueFromAttribute2 = XmlSiteMap.GetStringValueFromAttribute(xmlNode, "controller");
            string stringValueFromAttribute3 = XmlSiteMap.GetStringValueFromAttribute(xmlNode, "action");
            string stringValueFromAttribute4 = XmlSiteMap.GetStringValueFromAttribute(xmlNode, "url");
            string stringValueFromAttribute5 = XmlSiteMap.GetStringValueFromAttribute(xmlNode, "area");

            if (stringValueFromAttribute5 != null)
            {
                routeValueDictionary["area"] = stringValueFromAttribute5;
            }
            if (!string.IsNullOrEmpty(stringValueFromAttribute))
            {
                siteMapNode.RouteName = stringValueFromAttribute;
                siteMapNode.RouteValues.Clear();
                siteMapNode.RouteValues.Merge(routeValueDictionary);
            }
            else
            {
                if (!string.IsNullOrEmpty(stringValueFromAttribute2) && !string.IsNullOrEmpty(stringValueFromAttribute3))
                {
                    siteMapNode.ControllerName = stringValueFromAttribute2;
                    siteMapNode.ActionName     = stringValueFromAttribute3;
                    siteMapNode.RouteValues.Clear();
                    siteMapNode.RouteValues.Merge(routeValueDictionary);
                }
                else
                {
                    if (!string.IsNullOrEmpty(stringValueFromAttribute4))
                    {
                        siteMapNode.Url = stringValueFromAttribute4;
                    }
                }
            }
            DateTime?dateValueFromAttribute = XmlSiteMap.GetDateValueFromAttribute(xmlNode, "lastModifiedAt");

            if (dateValueFromAttribute.HasValue)
            {
                siteMapNode.LastModifiedAt = new DateTime?(dateValueFromAttribute.Value);
            }
            siteMapNode.IncludeInSearchEngineIndex = XmlSiteMap.GetBooleanValueFromAttribute(xmlNode, "includeInSearchEngineIndex", true);
            foreach (XmlAttribute xmlAttribute in xmlNode.Attributes)
            {
                if (!string.IsNullOrEmpty(xmlAttribute.LocalName) && Array.BinarySearch <string>(XmlSiteMap.knownAttributes, xmlAttribute.LocalName, StringComparer.OrdinalIgnoreCase) < 0)
                {
                    siteMapNode.Attributes.Add(xmlAttribute.LocalName, xmlAttribute.Value);
                }
            }
        }