コード例 #1
0
        /// <summary>
        /// Reads the typical attributes for a SecureWebPageItem from the configuration node.
        /// </summary>
        /// <param name="node">The XmlNode to read from.</param>
        /// <param name="item">The SecureWebPageItem to set values for.</param>
        protected void ReadChildItem(XmlNode node, SecureWebPageItem item)
        {
            // Set the item only if the node has a valid path attribute value
            if (node.Attributes["path"] != null && node.Attributes["path"].Value.Trim().Length > 0)
            {
                // Get the value of the path attribute
                item.Path = node.Attributes["path"].Value.Trim().ToLower();

                // Add leading and trailing "/" characters where needed
                if (item.Path.Length > 1)
                {
                    // Leading "/"
                    if (!item.Path.StartsWith("/"))
                    {
                        item.Path = "/" + item.Path;
                    }

                    // Trailing "/" only if this is a directory item
                    if (item is SecureWebPageDirectory && !item.Path.EndsWith("/"))
                    {
                        item.Path += "/";
                    }
                }

                // Check for a secure attribute
                if (node.Attributes["secure"] != null)
                {
                    switch (node.Attributes["secure"].Value.Trim().ToLower())
                    {
                    case "true":
                        item.Secure = SecurityType.Secure;
                        break;

                    case "false":
                        item.Secure = SecurityType.Insecure;
                        break;

                    case "ignore":
                        item.Secure = SecurityType.Ignore;
                        break;

                    default:
                        throw new SecureWebPageSectionException("Invalid value for the 'secure' attribute.", node);
                    }
                }
            }
            else
            {
                // Throw an exception for the missing Path attribute
                throw new SecureWebPageSectionException("'path' attribute not found.", node);
            }
        }
コード例 #2
0
 /// <summary>
 /// Returns the index of a specified item in the collection.
 /// </summary>
 /// <param name="item">The item to find.</param>
 /// <returns>Returns the index of the item.</returns>
 public int IndexOf(SecureWebPageItem item)
 {
     return(List.IndexOf(item));
 }