public void ParseOverrides2()
        {
            var pathspec = "/Arbor Memorial/(en|fr)/What We Do/*";
            var input    = pathspec + @" => {""priority"":0.8}";

            var expected = new Override()
            {
                PathSpec           = pathspec,
                PathSpecRegex      = SitemapUtils.PathspecToRegex(pathspec),
                OverrideProperties = new Serialization.@override()
                {
                    changefreq = null, priority = 0.8f
                }
            };

            var sitemapinput = CreateSitemapInput();
            var overrides    = sitemapinput._ParseOverrides(new string[] { input });

            overrides.Should().BeEquivalentTo(expected);
        }
        public void ParseOverrides(string input, string pathspec_value)
        {
            var expected =
                new Override()
            {
                PathSpec           = pathspec_value,
                PathSpecRegex      = SitemapUtils.PathspecToRegex(pathspec_value),
                OverrideProperties = new Serialization.@override()
                {
                    changefreq = "daily", priority = 0.5f
                }
            };
            var lines = new string[] { input };

            var sitemapinput = CreateSitemapInput();
            var overrides    = sitemapinput._ParseOverrides(lines);

            overrides.Should().HaveCount(1);
            overrides.Should().Equal(expected);
        }
示例#3
0
        internal IEnumerable <UrlMetaEntry> _ParseOverrides(IEnumerable <string> input)
        {
            var parsedOverrides = new List <UrlMetaEntry>();

            Regex r = new Regex(@"(.*)\s=>\s(.*)");

            foreach (var line in input)
            {
                var m = r.Match(line);
                if (m.Success)
                {
                    var overrideEntry = new UrlMetaEntry()
                    {
                        PathSpec      = m.Groups[1].Value,
                        PathSpecRegex = SitemapUtils.PathspecToRegex(m.Groups[1].Value),
                        Meta          = (CPContrib.SiteMap.Serialization.UrlMeta)Util.DeserializeDataContractJson(m.Groups[2].Value, typeof(CPContrib.SiteMap.Serialization.UrlMeta))
                    };
                    parsedOverrides.Add(overrideEntry);
                }
            }

            return(parsedOverrides);
        }