/// <summary>
        /// Acquires the attributes from a given <see cref="T:IMvcSiteMapNodeAttribute"/>
        /// </summary>
        /// <param name="attribute">The attribute.</param>
        /// <returns></returns>
        protected virtual void AcquireAttributesFrom(IMvcSiteMapNodeAttribute attribute, IDictionary <string, object> attributes)
        {
            foreach (var att in attribute.Attributes)
            {
                var attributeName  = att.Key.ToString();
                var attributeValue = att.Value;

                if (reservedAttributeNameProvider.IsRegularAttribute(attributeName))
                {
                    attributes[attributeName] = attributeValue;
                }
            }
        }
        /// <summary>
        /// Acquires the attributes from a given XElement.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <returns></returns>
        protected virtual void AcquireAttributesFrom(XElement node, IDictionary <string, object> attributes)
        {
            foreach (XAttribute attribute in node.Attributes())
            {
                var attributeName  = attribute.Name.ToString();
                var attributeValue = attribute.Value;

                if (reservedAttributeNameProvider.IsRegularAttribute(attributeName))
                {
                    attributes.Add(attributeName, attributeValue);
                }
            }
        }
示例#3
0
        /// <summary>
        /// Acquires the attributes from a given <see cref="T:System.Web.SiteMapNode"/>.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <returns></returns>
        protected virtual void AcquireAttributesFrom(System.Web.SiteMapNode node, IDictionary <string, object> attributes)
        {
            // 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.IsRegularAttribute(attributeName))
                {
                    attributes.Add(attributeName, attributeValue);
                }
            }
        }