public async Task <IHttpActionResult> Get(string url = "", int depth = 0, int contentDepth = 1, string includeInMeta = null)
        {
            var content = GetByRouteAndCulture($"/{url}");

            if (content == null)
            {
                return(NotFound());
            }

            var interceptor = _interceptorFactory.GetInterceptorByDocumentTypeAlias(content.ContentType.Alias);

            if (interceptor != null)
            {
                return(await interceptor.Intercept(content));
            }

            string[] includeInMetaParam = string.IsNullOrWhiteSpace(includeInMeta) ? new string[] { } : includeInMeta.Split(',');

            return(Ok(DynamicObject.Merge(
                          _metaPropertyResolverService.Resolve(content),
                          _contentResolverService.Resolve(content, null),
                          new
            {
                Navigation = _navigationTreeResolverService.Resolve(content,
                                                                    new NavigationTreeResolverSettings()
                {
                    Depth = depth, ContentDepth = contentDepth, ContentToIncludeInMetaProperties = includeInMetaParam
                })
            })) as IHttpActionResult);
        }
Beispiel #2
0
        private dynamic Resolve(IPublishedContent content)
        {
            if (content == null)
            {
                return(null);
            }

            if (content.ContentType.Alias == "Image")
            {
                return(ResolveProperty(content, "Image"));
            }

            return(DynamicObject.Merge(_metaPropertyResolverService.Resolve(content), Resolve(content, null)));
        }
Beispiel #3
0
        private IEnumerable <dynamic> Resolve(IPublishedContent content, int depth, int contentDepth, int currentDepth, string [] includeInMetaParam)
        {
            if (depth > 0 && depth <= currentDepth)
            {
                return new object[] {}
            }
            ;

            return(content.Children.Select(s =>
                                           DynamicObject.Merge(_metaPropertyResolverService.Resolve(s),
                                                               _contentResolverService.Resolve(s, includeInMetaParam),
                                                               contentDepth == 0 || contentDepth > currentDepth ? (object)_contentResolverService.Resolve(s, null) : new {},
                                                               depth == 0 || depth > currentDepth ? (object)new { Navigation = Resolve(s, depth, contentDepth, currentDepth + 1, includeInMetaParam) } : new {})
                                           ));
        }
    }