Beispiel #1
0
        /// <summary>
        /// Constructor used to create a new handler for multi-tenency with domains and ids
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="contentUrls"></param>
        /// <param name="itemsForRoute"></param>
        public ArticulateVirtualNodeByIdRouteHandler(ILogger logger, ContentUrls contentUrls, IEnumerable <IPublishedContent> itemsForRoute)
        {
            _logger          = logger;
            _lazyHostsAndIds = new Lazy <Dictionary <string, int> >(() =>
            {
                //make this lazy so we can reduce the startup overhead

                var hostsAndIds = new Dictionary <string, int>(StringComparer.InvariantCultureIgnoreCase);
                foreach (var publishedContent in itemsForRoute)
                {
                    var allUrls = contentUrls.GetContentUrls(publishedContent);

                    foreach (var url in allUrls)
                    {
                        //if there is a double slash, it will have a domain
                        if (url.Contains("//"))
                        {
                            var uri = new Uri(url, UriKind.Absolute);
                            hostsAndIds[uri.Host] = publishedContent.Id;
                        }
                        else
                        {
                            hostsAndIds[string.Empty] = publishedContent.Id;
                        }
                    }

                    _logger.Debug <ArticulateVirtualNodeByIdRouteHandler>("Hosts/IDs map for node {NodeId}. Values: {ArticulateHostValues}", publishedContent.Id, DebugHostIdsCollection(hostsAndIds));
                }

                return(hostsAndIds);
            });
        }
Beispiel #2
0
 public ArticulateRoutes(IUmbracoContextFactory umbracoContextFactory, ILogger logger, ContentUrls contentUrls, MetaWeblogHandlerFactory metaWeblogHandlerFactory)
 {
     _umbracoContextFactory    = umbracoContextFactory;
     _metaWeblogHandlerFactory = metaWeblogHandlerFactory;
     _logger      = logger;
     _contentUrls = contentUrls;
 }
 public ArticulateSearchRouteHandler(ILogger logger, ContentUrls contentUrls, IEnumerable <IPublishedContent> itemsForRoute)
     : base(logger, contentUrls, itemsForRoute)
 {
     foreach (var node in itemsForRoute)
     {
         _urlNames.Add(new UrlNames
         {
             NodeId         = node.Id,
             SearchUrlName  = node.Value <string>("searchUrlName"),
             SearchPageName = node.Value <string>("searchPageName")
         });
     }
 }
Beispiel #4
0
 /// <summary>
 /// Constructor used to create a new handler for multi-tenency with domains and ids
 /// </summary>
 /// <param name="contentUrls"></param>
 /// <param name="itemsForRoute"></param>
 /// <param name="logger"></param>
 public ArticulateTagsRouteHandler(ILogger logger, ContentUrls contentUrls, IEnumerable <IPublishedContent> itemsForRoute)
     : base(logger, contentUrls, itemsForRoute)
 {
     foreach (var node in itemsForRoute)
     {
         _urlsAndPageNames.Add(new UrlAndPageNames
         {
             NodeId             = node.Id,
             TagsUrlName        = node.Value <string>("tagsUrlName"),
             TagsPageName       = node.Value <string>("tagsPageName"),
             CategoriesUrlName  = node.Value <string>("categoriesUrlName"),
             CategoriesPageName = node.Value <string>("categoriesPageName")
         });
     }
 }
        public TagsOrCategoryPathRouteConstraint(ContentUrls contentUrls, IEnumerable <IPublishedContent> itemsForRoute)
        {
            if (itemsForRoute == null)
            {
                throw new ArgumentNullException(nameof(itemsForRoute));
            }

            var urlNames = new List <UrlNames>();

            foreach (var node in itemsForRoute)
            {
                var allUrls = contentUrls.GetContentUrls(node);

                foreach (var url in allUrls)
                {
                    //if there is a double slash, it will have a domain
                    if (url.Contains("//"))
                    {
                        var uri = new Uri(url, UriKind.Absolute);
                        urlNames.Add(new UrlNames
                        {
                            Host            = uri.Host,
                            CategoryUrlName = node.Value <string>("categoriesUrlName"),
                            TagsUrlName     = node.Value <string>("tagsUrlName")
                        });
                    }
                    else
                    {
                        urlNames.Add(new UrlNames
                        {
                            Host            = string.Empty,
                            CategoryUrlName = node.Value <string>("categoriesUrlName"),
                            TagsUrlName     = node.Value <string>("tagsUrlName")
                        });
                    }
                }
            }

            _urlNames = urlNames;
        }