/// <summary>
        /// Returns a query that can be used to look up the CustomEntityRoute relating
        /// to the matched entity. Throws an exception if the MatchesRule returns false, so
        /// check this before calling this method.
        /// </summary>
        /// <param name="url">The url to parse custom entity key data from</param>
        /// <param name="pageRoute">The page route matched to the url</param>
        /// <returns>An IQuery object that can used to query for the CustomEntityRoute</returns>
        public IQuery <CustomEntityRoute> ExtractRoutingQuery(string url, PageRoute pageRoute)
        {
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }
            if (string.IsNullOrWhiteSpace(url))
            {
                throw new ArgumentEmptyException(nameof(url));
            }
            if (pageRoute == null)
            {
                throw new ArgumentNullException(nameof(pageRoute));
            }

            if (!MatchesRule(url, pageRoute))
            {
                throw new ArgumentException(nameof(url) + $" does not match the specified page route. {nameof(ExtractRoutingQuery)} can only be called after a successful page route match.", nameof(url));
            }

            var routingPart    = GetRoutingPart(url, pageRoute);
            var customEntityId = IntParser.ParseOrDefault(routingPart);

            var query = new GetCustomEntityRouteByPathQuery();

            query.CustomEntityDefinitionCode = pageRoute.CustomEntityDefinitionCode;
            query.CustomEntityId             = customEntityId;

            if (pageRoute.Locale != null)
            {
                query.LocaleId = pageRoute.Locale.LocaleId;
            }

            return(query);
        }
예제 #2
0
        public IQuery <CustomEntityRoute> ExtractRoutingQuery(string url, PageRoute pageRoute)
        {
            Condition.Requires(url).IsNotNullOrWhiteSpace();
            Condition.Requires(pageRoute).IsNotNull();
            Condition.Requires(MatchesRule(url, pageRoute)).IsTrue();

            var slugUrlPart = GetRoutingPart(url, pageRoute);

            var query = new GetCustomEntityRouteByPathQuery()
            {
                CustomEntityDefinitionCode = pageRoute.CustomEntityDefinitionCode,
                UrlSlug = slugUrlPart
            };

            if (pageRoute.Locale != null)
            {
                query.LocaleId = pageRoute.Locale.LocaleId;
            }

            return(query);
        }
        public IQuery <CustomEntityRoute> ExtractRoutingQuery(string url, PageRoute pageRoute)
        {
            Condition.Requires(url).IsNotNullOrWhiteSpace();
            Condition.Requires(pageRoute).IsNotNull();
            Condition.Requires(MatchesRule(url, pageRoute)).IsTrue();

            var routingPart = GetRoutingPart(url, pageRoute);

            var match = Regex.Match(routingPart, ROUTE_REGEX);

            var query = new GetCustomEntityRouteByPathQuery();

            query.CustomEntityDefinitionCode = pageRoute.CustomEntityDefinitionCode;
            query.CustomEntityId             = Convert.ToInt32(match.Groups[1].Value);

            if (pageRoute.Locale != null)
            {
                query.LocaleId = pageRoute.Locale.LocaleId;
            }

            return(query);
        }
        /// <summary>
        /// Returns a query that can be used to look up the CustomEntityRoute relating
        /// to the matched entity. Throws an exception if the MatchesRule returns false, so
        /// check this before calling this method.
        /// </summary>
        /// <param name="url">The url to parse custom entity key data from</param>
        /// <param name="pageRoute">The page route matched to the url</param>
        /// <returns>An IQuery object that can used to query for the CustomEntityRoute</returns>
        public IQuery <CustomEntityRoute> ExtractRoutingQuery(string url, PageRoute pageRoute)
        {
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }
            if (string.IsNullOrWhiteSpace(url))
            {
                throw new ArgumentEmptyException(nameof(url));
            }
            if (pageRoute == null)
            {
                throw new ArgumentNullException(nameof(pageRoute));
            }

            if (!MatchesRule(url, pageRoute))
            {
                throw new ArgumentException(nameof(url) + $" does not match the specified page route. {nameof(ExtractRoutingQuery)} can only be called after a successful page route match.", nameof(url));
            }

            var routingPart = GetRoutingPart(url, pageRoute);

            var match = Regex.Match(routingPart, ROUTE_REGEX);

            var query = new GetCustomEntityRouteByPathQuery();

            query.CustomEntityDefinitionCode = pageRoute.CustomEntityDefinitionCode;
            query.CustomEntityId             = Convert.ToInt32(match.Groups[1].Value);

            if (pageRoute.Locale != null)
            {
                query.LocaleId = pageRoute.Locale.LocaleId;
            }

            return(query);
        }
예제 #5
0
 public Task <CustomEntityRoute> GetCustomEntityRouteByPathAsync(GetCustomEntityRouteByPathQuery query, IExecutionContext executionContext = null)
 {
     return(_queryExecutor.ExecuteAsync(query, executionContext));
 }
 public Task <CustomEntityRoute> AsCustomEntityRoute(GetCustomEntityRouteByPathQuery query)
 {
     return(ExtendableContentRepository.ExecuteQueryAsync(query));
 }
예제 #7
0
 public IContentRepositoryQueryContext <CustomEntityRoute> AsCustomEntityRoute(GetCustomEntityRouteByPathQuery query)
 {
     return(ContentRepositoryQueryContextFactory.Create(query, ExtendableContentRepository));
 }