private static DateTime?GetDateValueFromAttribute(XmlNode node, string attributeName) { string stringValueFromAttribute = XmlSiteMap.GetStringValueFromAttribute(node, attributeName); DateTime?result = null; DateTime value; if (!string.IsNullOrEmpty(stringValueFromAttribute) && DateTime.TryParse(stringValueFromAttribute, out value)) { result = new DateTime?(value); } return(result); }
private static bool GetBooleanValueFromAttribute(XmlNode node, string attributeName, bool defaultValue) { bool result = defaultValue; string stringValueFromAttribute = XmlSiteMap.GetStringValueFromAttribute(node, attributeName); bool flag; if (!string.IsNullOrEmpty(stringValueFromAttribute) && bool.TryParse(stringValueFromAttribute, out flag)) { result = flag; } return(result); }
private static float GetFloatValueFromAttribute(XmlNode node, string attributeName, float defaultValue) { float result = defaultValue; string stringValueFromAttribute = XmlSiteMap.GetStringValueFromAttribute(node, attributeName); float num; if (!string.IsNullOrEmpty(stringValueFromAttribute) && float.TryParse(stringValueFromAttribute, out num)) { result = num; } return(result); }
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); } } }