/// <summary>
        /// Acquires the route values from a given XElement.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <returns></returns>
        protected virtual void AcquireRouteValuesFrom(IMvcSiteMapNodeAttribute attribute, IRouteValueDictionary routeValues)
        {
            foreach (var att in attribute.Attributes)
            {
                var attributeName  = att.Key.ToString();
                var attributeValue = att.Value;

                if (reservedAttributeNameProvider.IsRouteAttribute(attributeName))
                {
                    routeValues[attributeName] = attributeValue;
                }
            }
        }
        /// <summary>
        /// Acquires the route values from a given XElement.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <returns></returns>
        protected virtual void AcquireRouteValuesFrom(XElement node, IRouteValueDictionary routeValues)
        {
            foreach (XAttribute attribute in node.Attributes())
            {
                var attributeName  = attribute.Name.ToString();
                var attributeValue = attribute.Value;

                if (reservedAttributeNameProvider.IsRouteAttribute(attributeName))
                {
                    routeValues.Add(attributeName, attributeValue);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Acquires the route values from a given <see cref="T:System.Web.SiteMapNode"/>.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <returns></returns>
        protected virtual void AcquireRouteValuesFrom(System.Web.SiteMapNode node, IRouteValueDictionary routeValues)
        {
            // Unfortunately, the ASP.NET implementation uses a protected member variable to store
            // the attributes, so there is no way to loop through them without reflection or some
            // fancy dynamic subclass implementation.
            var attributeDictionary = node.GetPrivateFieldValue <NameValueCollection>("_attributes");

            foreach (string key in attributeDictionary.Keys)
            {
                var attributeName  = key;
                var attributeValue = node[key];

                if (reservedAttributeNameProvider.IsRouteAttribute(attributeName))
                {
                    routeValues.Add(attributeName, attributeValue);
                }
            }
        }