public static async Task <string> DocumentUrl(this IUrlHelper url, ISanityDocument document, CultureInfo language)
        {
            var urlResolver = url.ActionContext.HttpContext.RequestServices.GetRequiredService <IUrlResolver>();

            return(await urlResolver
                   .GetUrl(document, language));
        }
예제 #2
0
        public override async Task <string> GetUrl(ISanityDocument document, CultureInfo language)
        {
            if (document == null)
            {
                return(null);
            }

            return(await GetUrl(document.Id, language));
        }
 public TemplateResolvingNotification(
     ISanityDocument content,
     ContentControllerDescriptor resolvedTemplate,
     IEnumerable <ContentControllerDescriptor> availableTemplates)
 {
     Content            = content;
     ResolvedTemplate   = resolvedTemplate;
     AvailableTemplates = availableTemplates;
 }
예제 #4
0
        private bool IsValidParent(SegmentContext segmentContext, ISanityDocument document)
        {
            if (document.Parent == null)
            {
                return(true);
            }

            var indexOfParent = segmentContext.ConsumedDocuments.IndexOf(document.Parent.Id);

            return(indexOfParent > -1 && indexOfParent == segmentContext.ConsumedDocuments.Count - 2);
        }
        public virtual ContentControllerDescriptor Resolve(ISanityDocument document)
        {
            var controllerDescriptors = _typeScanner
                                        .GetControllerDescriptors()
                                        .Where(x => x.ForContentType.IsInstanceOfType(document))
                                        .ToList();
            var resolved = controllerDescriptors.FirstOrDefault();

            var notification = new TemplateResolvingNotification(document, resolved, controllerDescriptors);

            _mediator.Publish(notification);
            return(notification.ResolvedTemplate);
        }
 public static async Task <string> DocumentUrl(this IUrlHelper url, ISanityDocument document)
 {
     return(await url.DocumentUrl(document, CultureInfo.CurrentUICulture));
 }