Exemplo n.º 1
0
        public async Task UpdateSitemapAsync(SitemapType sitemap)
        {
            var existing = await LoadDocumentAsync();

            existing.Sitemaps[sitemap.SitemapId] = sitemap;
            sitemap.Identifier = IdGenerator.GenerateId();
            await _documentManager.UpdateAsync(existing);
        }
        public async Task BuildAsync(SitemapType sitemap, SitemapBuilderContext context)
        {
            var tSitemap = sitemap as TSitemapType;

            if (tSitemap != null)
            {
                await BuildSitemapTypeAsync(tSitemap, context);
            }
        }
Exemplo n.º 3
0
        public async Task SaveSitemapAsync(string sitemapId, SitemapType sitemap)
        {
            if (sitemap.IsReadonly)
            {
                throw new ArgumentException("The object is read-only");
            }

            var existing = await LoadDocumentAsync();

            existing.Sitemaps.Remove(sitemapId);
            existing.Sitemaps[sitemapId] = sitemap;

            _session.Save(existing);
            _signal.DeferredSignalToken(SitemapsDocumentCacheKey);

            BuildAllSitemapRouteEntries(existing);

            return;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Parse a sitemap with the <see cref="SitemapType"/> specified.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="rawSitemap"></param>
        /// <returns></returns>
        public SitemapFile ParseSitemap(SitemapType type, string rawSitemap)
        {
            if (rawSitemap == null)
            {
                return(null);
            }

            ISitemapReader reader;

            if (type == SitemapType.Xml)
            {
                reader = new XmlSitemapReader();
                return(reader.ParseSitemap(rawSitemap));
            }
            else
            {
                return(null);
            }
        }
        public async Task <DateTime?> GetLastModifiedDateAsync(SitemapType sitemap)
        {
            DateTime?lastModifiedDate = null;

            foreach (var source in sitemap.SitemapSources)
            {
                foreach (var modifiedDateProviders in _sitemapSourceModifiedDateProviders)
                {
                    var result = await modifiedDateProviders.GetLastModifiedDateAsync(source);

                    if (result.HasValue && (lastModifiedDate == null || result.Value > lastModifiedDate))
                    {
                        lastModifiedDate = result;
                    }
                }
            }

            return(lastModifiedDate);
        }
Exemplo n.º 6
0
        public async Task <XDocument> BuildAsync(SitemapType sitemap, SitemapBuilderContext context)
        {
            if (!sitemap.Enabled)
            {
                return(null);
            }

            foreach (var sitemapTypeBuilder in _sitemapTypeBuilders)
            {
                await sitemapTypeBuilder.BuildAsync(sitemap, context);

                if (context.Response != null)
                {
                    var document = new XDocument(context.Response.ResponseElement);

                    return(new XDocument(document));
                }
            }

            return(null);
        }