private static RobotsTxtConfiguration CreateNewConfiguration()
        {
            RobotsTxtConfiguration output = new RobotsTxtConfiguration();

            var root = Sitecore.Configuration.Factory.GetConfigNode("constellation/robotsTxt");

            if (root == null)
            {
                var ex = new Exception(" No constellation/robotsTxt configuration found.");
                Log.Error("Constellation.Foundation.SitemapXml: error loading configuration.", ex, output);
                throw ex;
            }

            var globalsNode = Sitecore.Configuration.Factory.GetConfigNode("constellation/robotsTxt/globalRules");

            if (globalsNode != null && globalsNode.HasChildNodes)
            {
                foreach (XmlNode node in globalsNode.ChildNodes)
                {
                    output.GlobalRules.Add(new RobotsTxtRule(node));
                }
            }

            var defaultsNode = Sitecore.Configuration.Factory.GetConfigNode("constellation/robotsTxt/defaultRules");

            if (defaultsNode != null && defaultsNode.HasChildNodes)
            {
                foreach (XmlNode node in defaultsNode.ChildNodes)
                {
                    output.DefaultRules.Add(new RobotsTxtRule(node));
                }
            }

            var sitesNode = Sitecore.Configuration.Factory.GetConfigNode("constellation/robotsTxt/siteRules");

            if (sitesNode != null && sitesNode.HasChildNodes)
            {
                foreach (XmlNode site in sitesNode.ChildNodes)
                {
                    if (!site.HasChildNodes)
                    {
                        continue;
                    }

                    var list = new List <RobotsTxtRule>();

                    foreach (XmlNode node in site.ChildNodes)
                    {
                        list.Add(new RobotsTxtRule(node));
                    }

                    output.SiteRules.Add(site.Name, list);
                }
            }

            return(output);
        }
        private static RobotsTxtConfiguration CreateNewConfiguration()
        {
            RobotsTxtConfiguration output = new RobotsTxtConfiguration();

            var root = Sitecore.Configuration.Factory.GetConfigNode("constellation/robotsTxt");

            if (root == null)
            {
                var ex = new Exception(" No constellation/robotsTxt configuration found.");
                Log.Error("Constellation.Foundation.SitemapXml: error loading configuration.", ex, output);
                throw ex;
            }

            if (bool.TryParse(root.Attributes?["allowed"]?.Value, out var allowed))
            {
                output.Allowed = allowed;
            }

            var globalsNode = Sitecore.Configuration.Factory.GetConfigNode("constellation/robotsTxt/globalDisallows");

            if (globalsNode != null && globalsNode.HasChildNodes)
            {
                foreach (XmlNode disallow in globalsNode.ChildNodes)
                {
                    output.GlobalDisallows.Add(disallow.InnerText);
                }
            }

            var sitesNode = Sitecore.Configuration.Factory.GetConfigNode("constellation/robotsTxt/siteDisallows");

            if (sitesNode != null && sitesNode.HasChildNodes)
            {
                foreach (XmlNode site in sitesNode.ChildNodes)
                {
                    if (!site.HasChildNodes)
                    {
                        continue;
                    }

                    var list = new List <string>();

                    foreach (XmlNode disallow in site.ChildNodes)
                    {
                        list.Add(disallow.InnerText);
                    }

                    output.SiteDisallows.Add(site.Name, list);
                }
            }

            return(output);
        }