Пример #1
0
        private void AddSite(HostSection hostSection, SiteElement element)
        {
            Site site = new Site(hostSection.RootItemID, element.StartPageID, element.SiteHosts);
            site.Wildcards = hostSection.Wildcards || element.Wildcards;
            _sites.Add(site);

            if (element.SiteHosts == null || element.SiteHosts.Count == 0)
                SetFallbackSettings(site);
            else
                foreach (HostNameElement hostName in element.SiteHosts)
                {
                    if (_hostToSites.ContainsKey(hostName.Name))
                        throw new ConfigurationErrorsException("A host name can occur only once. " + hostName.Name + "in <siteHosts> has already been defined.");

                    if (hostName.Name == "*")
                        SetFallbackSettings(site);
                    else
                        _hostToSites.Add(hostName.Name, site);
                }
        }
Пример #2
0
        private static string GetHostedUrl(ContentItem item, string url, Site site)
        {
            string hostName = site.GetHostName(item.Language);
            if (string.IsNullOrEmpty(hostName))
                return item.FindPath(PathData.DefaultAction).RewrittenUrl;

            return Url.Parse(url).SetAuthority(hostName);
        }
Пример #3
0
 protected static bool IsStartPage(ContentItem item, Site site)
 {
     return item.ID == site.StartPageID || (item.TranslationOf != null && item.TranslationOf.ID == site.StartPageID);
 }
Пример #4
0
 private void SetFallbackSettings(Site site)
 {
     if (_hostToSites.ContainsKey("*"))
         throw new ConfigurationErrorsException("Only one <site> section without a <siteHosts> element is allowed. A <siteHosts> <add name=\"*\" /> </siteHosts> is the same as not defining a siteHosts element.");
     _hostToSites.Add("*", site);
 }