public void Get_Url_Alternate()
        {
            SetDomains5();

            var requestHandlerSettings = new RequestHandlerSettings {
                AddTrailingSlash = true
            };

            GlobalSettings.HideTopLevelNodeFromPath = false;

            var         umbracoContextAccessor = GetUmbracoContextAccessor("http://domain1.com/en/test");
            UrlProvider urlProvider            = GetUrlProvider(umbracoContextAccessor, requestHandlerSettings, new WebRoutingSettings(), out UriUtility uriUtility);


            var url = urlProvider.GetUrl(100111, UrlMode.Absolute);

            Assert.AreEqual("http://domain1.com/en/1001-1-1/", url);

            var result = urlProvider.GetOtherUrls(100111).ToArray();

            foreach (var x in result)
            {
                Console.WriteLine(x);
            }

            Assert.AreEqual(2, result.Length);
            Assert.AreEqual(result[0].Text, "http://domain1b.com/en/1001-1-1/");
            Assert.AreEqual(result[1].Text, "http://domain1a.com/en/1001-1-1/");
        }
        /// <summary>
        /// Returns the content item URLs taking into account any domains assigned
        /// </summary>
        /// <param name="umbracoUrlProvider"></param>
        /// <param name="publishedContent"></param>
        /// <returns></returns>
        internal static HashSet <string> GetContentUrls(UrlProvider umbracoUrlProvider, IPublishedContent publishedContent)
        {
            HashSet <string> allUrls;
            var other = umbracoUrlProvider.GetOtherUrls(publishedContent.Id).ToArray();

            if (other.Length > 0)
            {
                //this means there are domains assigned
                allUrls = new HashSet <string>(other)
                {
                    umbracoUrlProvider.GetUrl(publishedContent.Id, UrlProviderMode.Absolute)
                };
            }
            else
            {
                allUrls = new HashSet <string>()
                {
                    publishedContent.Url
                };
            }
            return(allUrls);
        }
        private bool AddContentToCache(int rootContentId, int contentId, UrlProvider urlProvider, bool deleteExisting = false, string matchingId = null)
        {
            var matchFound = false;

            try
            {
                _locker.TryEnterWriteLock(VortoUrlService.Current.CacheWriteTimeout);

                var contentIdStr = contentId.ToString();

                if (deleteExisting)
                {
                    var nodesForItem = GetElementsByAttributeValue(_elementAttributeNameContentId, contentIdStr).ToList();
                    foreach (var node in nodesForItem)
                    {
                        node.Remove();
                    }
                }

                var id = GetElementIdFromUrl(rootContentId, urlProvider.GetUrl(contentId, false));
                if (string.IsNullOrWhiteSpace(id))
                {
                    return(false);
                }
                if (id == matchingId)
                {
                    matchFound = true;
                }
                if (GetElementById(id) == null)
                {
                    GetParentElement(id).AddFirst(CreateElement(id, contentIdStr));
                }

                var otherUrlIds = urlProvider
                                  .GetOtherUrls(contentId)
                                  .Select(x => GetElementIdFromUrl(rootContentId, x))
                                  .Distinct();
                foreach (var otherId in otherUrlIds)
                {
                    if (otherId == id)
                    {
                        continue;
                    }
                    if (otherId == matchingId)
                    {
                        matchFound = true;
                    }
                    if (GetElementById(otherId) == null)
                    {
                        GetParentElement(otherId).AddFirst(CreateElement(otherId, contentIdStr));
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(MethodBase.GetCurrentMethod().DeclaringType, "Something went wrong trying to write to the in-memory cache", ex);
            }
            finally
            {
                _locker.ExitWriteLock();
            }

            return(matchFound);
        }