public XmlAuthorizationPath()
 {
     Allow    = new XmlAuthorizationRule(AuthorizationRuleAction.Allow);
     Deny     = new XmlAuthorizationRule(AuthorizationRuleAction.Deny);
     Children = new List <XmlAuthorizationPath>();
 }
        /// <summary>
        /// Construtor padrão.
        /// </summary>
        /// <param name="parent">Elemento pai.</param>
        /// <param name="element"></param>
        public XmlAuthorizationPath(XmlAuthorizationPath parent, XmlElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            Parent   = parent;
            Children = new List <XmlAuthorizationPath>();
            Url      = element.GetAttribute("url");
            FullUrl  = (parent != null && !string.IsNullOrEmpty(parent.FullUrl) ? parent.FullUrl + "/" : "") + Url;
            var complexParts = Regex.Matches(FullUrl, "{[0-9]*?}", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture);

            if (complexParts.Count > 0)
            {
                var complexRegex = FullUrl;
                var partNumber   = 0;
                foreach (Match i in complexParts)
                {
                    complexRegex = complexRegex.Replace(i.Value, "(?<complex" + (partNumber++) + ">[\\s\\S]*?)");
                }
                Complex = new Regex(complexRegex);
            }
            if (element.HasChildNodes)
            {
                foreach (var i in element.ChildNodes)
                {
                    var node = i as XmlElement;
                    if (node == null)
                    {
                        continue;
                    }
                    var name = node.Name.ToLower();
                    if (name == "allow")
                    {
                        Allow = new XmlAuthorizationRule(node);
                        _permissions.Add(Allow);
                    }
                    else if (name == "deny")
                    {
                        Deny = new XmlAuthorizationRule(node);
                        _permissions.Add(Deny);
                    }
                    else if (name == "paths" && node.HasChildNodes)
                    {
                        foreach (var j in node.ChildNodes)
                        {
                            var n1 = j as XmlElement;
                            if (n1.Name.ToLower() == "path")
                            {
                                Children.Add(new XmlAuthorizationPath(this, n1));
                            }
                        }
                    }
                }
            }
            if (Allow == null)
            {
                Allow = new XmlAuthorizationRule(AuthorizationRuleAction.Allow);
            }
            if (Deny == null)
            {
                Deny = new XmlAuthorizationRule(AuthorizationRuleAction.Deny);
            }
        }