public static bool GetAssignedWithCulture(this IDomainCache domainCache, string culture, int documentId, bool includeWildcards = false) { var assigned = domainCache.GetAssigned(documentId, includeWildcards); // It's super important that we always compare cultures with ignore case, since we can't be sure of the casing! return(culture is null?assigned.Any() : assigned.Any(x => x.Culture.Equals(culture, StringComparison.InvariantCultureIgnoreCase))); }
public static bool GetAssignedWithCulture(this IDomainCache domainCache, string?culture, int documentId, bool includeWildcards = false) { IEnumerable <Domain> assigned = domainCache.GetAssigned(documentId, includeWildcards); // It's super important that we always compare cultures with ignore case, since we can't be sure of the casing! // Comparing with string.IsNullOrEmpty since both empty string and null signifies invariant. return(string.IsNullOrEmpty(culture) ? assigned.Any() : assigned.Any(x => x.Culture?.Equals(culture, StringComparison.InvariantCultureIgnoreCase) ?? false)); }
/// <summary> /// Finds the domain for the specified node, if any, that best matches a specified uri. /// </summary> /// <param name="nodeId">The node identifier.</param> /// <param name="current">The uri, or null.</param> /// <param name="culture">The culture, or null.</param> /// <returns>The domain and its uri, if any, that best matches the specified uri and culture, else null.</returns> /// <remarks> /// <para>If at least a domain is set on the node then the method returns the domain that /// best matches the specified uri and culture, else it returns null.</para> /// <para>If culture is null, uses the default culture for the installation instead. Otherwise, /// will try with the specified culture, else return null.</para> /// </remarks> internal DomainAndUri DomainForNode(int nodeId, Uri current, string culture = null) { // be safe if (nodeId <= 0) { return(null); } // get the domains on that node var domains = _domainCache.GetAssigned(nodeId, false).ToArray(); // none? if (domains.Length == 0) { return(null); } // else filter // it could be that none apply (due to culture) return(SelectDomain(domains, current, culture, _domainCache.DefaultCulture, (cdomainAndUris, ccurrent, cculture, cdefaultCulture) => _siteDomainHelper.MapDomain(cdomainAndUris, ccurrent, cculture, cdefaultCulture))); }
/// <summary> /// Finds the domain for the specified node, if any, that best matches a specified uri. /// </summary> /// <param name="domainCache">A domain cache.</param> /// <param name="siteDomainMapper">The site domain helper.</param> /// <param name="nodeId">The node identifier.</param> /// <param name="current">The uri, or null.</param> /// <param name="culture">The culture, or null.</param> /// <returns>The domain and its uri, if any, that best matches the specified uri and culture, else null.</returns> /// <remarks> /// <para>If at least a domain is set on the node then the method returns the domain that /// best matches the specified uri and culture, else it returns null.</para> /// <para>If culture is null, uses the default culture for the installation instead. Otherwise, /// will try with the specified culture, else return null.</para> /// </remarks> internal static DomainAndUri?DomainForNode(IDomainCache?domainCache, ISiteDomainMapper siteDomainMapper, int nodeId, Uri current, string?culture = null) { // be safe if (nodeId <= 0) { return(null); } // get the domains on that node Domain[]? domains = domainCache?.GetAssigned(nodeId).ToArray(); // none? if (domains is null || domains.Length == 0) { return(null); } // else filter // it could be that none apply (due to culture) return(SelectDomain(domains, current, culture, domainCache?.DefaultCulture, siteDomainMapper.MapDomain)); }
/// <summary> /// Find the domains for the specified node, if any, that match a specified uri. /// </summary> /// <param name="domainCache">A domain cache.</param> /// <param name="siteDomainMapper">The site domain helper.</param> /// <param name="nodeId">The node identifier.</param> /// <param name="current">The uri, or null.</param> /// <param name="excludeDefault">A value indicating whether to exclude the current/default domain. True by default.</param> /// <returns>The domains and their uris, that match the specified uri, else null.</returns> /// <remarks>If at least a domain is set on the node then the method returns the domains that /// best match the specified uri, else it returns null.</remarks> internal static IEnumerable <DomainAndUri>?DomainsForNode(IDomainCache?domainCache, ISiteDomainMapper siteDomainMapper, int nodeId, Uri current, bool excludeDefault = true) { // be safe if (nodeId <= 0) { return(null); } // get the domains on that node Domain[]? domains = domainCache?.GetAssigned(nodeId).ToArray(); // none? if (domains is null || domains.Length == 0) { return(null); } // get the domains and their uris DomainAndUri[] domainAndUris = SelectDomains(domains, current).ToArray(); // filter return(siteDomainMapper.MapDomains(domainAndUris, current, excludeDefault, null, domainCache?.DefaultCulture).ToArray()); }
public static bool GetAssignedWithCulture(this IDomainCache domainCache, string culture, int documentId, bool includeWildcards = false) { var assigned = domainCache.GetAssigned(documentId, includeWildcards); return(culture is null?assigned.Any() : assigned.Any(x => x.Culture == culture)); }