/// <summary> /// Returns a list of URLs with the domains assigned based on the list of ancestorsOrSelf. If no domain is assigned to the branch that the entity exists in a null value is returned. /// </summary> /// <param name="ancestorsOrSelf">The ancestorsOrSelf list to create the URL for</param> /// <returns></returns> protected IEnumerable <UrlResolutionResult> GetDomainUrls(IEnumerable <TypedEntity> ancestorsOrSelf) { var reversed = ancestorsOrSelf.Reverse(); var parts = new List <string>(); //need to figure out a domain assigned to this node foreach (var a in reversed) { if (DomainList.ContainsContentId(a.Id)) { //ok, we've found a node with a domain assigned, return a list of URLs with all domains assigned to this id return(DomainList[a.Id] .Select(d => new UrlResolutionResult( (d.Hostname + _httpContext.Request.ApplicationPath.TrimEnd('/') + "/" + string.Join("/", Enumerable.Reverse(parts).ToArray())).TrimEnd('/'), UrlResolutionStatus.SuccessWithHostname)) .ToArray()); } else { var urlAlias = a.InnerAttribute <string>(NodeNameAttributeDefinition.AliasValue, "UrlName"); Mandate.That(!urlAlias.IsNullOrWhiteSpace(), x => new InvalidOperationException("UrlName cannot be empty")); parts.Add(urlAlias); } } //this will occur if no domains are found return(Enumerable.Empty <UrlResolutionResult>()); }