public ContentRendererSelector(IContentRenderer[] renderers) { this.renderers = renderers .OrderByDescending(r => Utility.InheritanceDepth(r.HandledContentType)) .ThenByDescending(r => Utility.InheritanceDepth(r.GetType())) .ToArray(); }
/// <inheritdoc/> public async Task RenderAsync(TextWriter output, Content parentContent, IContentPayload currentPayload, PropertyBag context) { if (!context.TryGet(PublicationStateContextKey, out PublicationStateToRender stateToRender)) { throw new InvalidOperationException($"The context must contain the '{PublicationStateContextKey}' property"); } if (currentPayload is PublicationWorkflowContentPayload payload) { ContentState contentState = await this.contentStore.GetContentStateForWorkflowAsync(payload.Slug, WellKnownWorkflowId.ContentPublication).ConfigureAwait(false); if (CanRender(contentState, stateToRender)) { Content content = await this.contentStore.GetContentAsync(contentState.ContentId, contentState.Slug).ConfigureAwait(false); IContentRenderer renderer = this.contentRendererFactory.GetRendererFor(content.ContentPayload); await renderer.RenderAsync(output, content, content.ContentPayload, context).ConfigureAwait(false); } else { // TODO: How are we rendering error/invalid/missing states? } } else { throw new ArgumentException(nameof(currentPayload)); } }
public ContentRendererInterceptor(IContentRenderer defaultRenderer, IHtmlCache htmlCache, ServiceAccessor <IContentRouteHelper> contentRouteHelperAccessor, IRenderingContextResolver contextResolver) { _defaultRenderer = defaultRenderer; _htmlCache = htmlCache; _contentRouteHelperAccessor = contentRouteHelperAccessor; _contextResolver = contextResolver; }
public ContentViewComponent( IContentRenderer contentRenderer, IContentPublicAppService contentAppService) { this.contentRenderer = contentRenderer; this.contentAppService = contentAppService; }
public NoWrappersContentAreaRenderer(IContentRenderer contentRenderer, TemplateResolver templateResolver, ContentRequestContext contentRequestContext) { _contentRenderer = contentRenderer; _templateResolver = templateResolver; _contentRequestContext = contentRequestContext; }
public DonutContentRenderer(IContentRenderer contentRenderer, TemplateResolver templateResolver, ContentFragmentAttributeAssembler attributeAssembler, IContentRepository contentRepository, DisplayOptions displayOptions) : base(contentRenderer, templateResolver, attributeAssembler, contentRepository, displayOptions) { }
public MyContentAreaRenderer( IContentAreaLoader contentAreaLoader, IContentRenderer contentRenderer, IContentAreaItemAttributeAssembler attributeAssembler) { _contentAreaLoader = contentAreaLoader; _contentRenderer = contentRenderer; _attributeAssembler = attributeAssembler; }
public CustomContentAreaRenderer(IContentRenderer contentRenderer, TemplateResolver templateResolver, IContentAreaItemAttributeAssembler attributeAssembler, IContentRepository contentRepository, IContentAreaLoader contentAreaLoader) : base(contentRenderer, templateResolver, attributeAssembler, contentRepository, contentAreaLoader) { _contentRenderer = contentRenderer; _templateResolver = templateResolver; _attributeAssembler = attributeAssembler; _contentRepository = contentRepository; }
public CacheableContentRendererService( IContentRenderer defaultRenderer, ICacheableSettingsService settingsService, ISynchronizedObjectInstanceCache cache, ICacheableKeyCreator keyCreator, IContentCacheKeyCreator contentCacheKeyCreator) { DefaultRenderer = defaultRenderer ?? throw new ArgumentNullException(nameof(defaultRenderer)); SettingsService = settingsService ?? throw new ArgumentNullException(nameof(settingsService)); Cache = cache ?? throw new ArgumentNullException(nameof(cache)); KeyCreator = keyCreator ?? throw new ArgumentNullException(nameof(keyCreator)); ContentCacheKeyCreator = contentCacheKeyCreator ?? throw new ArgumentNullException(nameof(contentCacheKeyCreator)); MasterCacheKeys = new[] { ContentCacheKeyCreator.VersionKey }; }
//protected HtmlHelper Html { get; set; } protected ControllerTests() { TestAuthenticationAndAuthorization.SetTestUserToCurrentPrincipal(); Repository = Substitute.For <IRepository>(); SettingsProvider = Substitute.For <ISettingsProvider>(); ContentRenderer = Substitute.For <IContentRenderer>(); ControllerContext = CreateControllerContext(); UrlHelper = CreateUrlHelper(); SettingsProvider.GetSettings <FunnelWebSettings>().Returns(new FunnelWebSettings { EnablePublicHistory = true }); //Html = CreateHelper(); ContentRenderer.RenderTrusted(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <HtmlHelper>()).Returns(c => c.Args()[0]); ContentRenderer.RenderUntrusted(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <HtmlHelper>()).Returns(c => c.Args()[0]); }
/// <inheritdoc/> public async Task RenderAsync(TextWriter output, Content parentContent, IContentPayload currentPayload, PropertyBag context) { if (currentPayload is CompoundPayload compoundPayload) { foreach (IContentPayload child in compoundPayload.Children) { IContentRenderer renderer = this.contentRendererFactory.GetRendererFor(child); await renderer.RenderAsync(output, parentContent, child, context).ConfigureAwait(false); } } else { throw new ArgumentException(nameof(currentPayload)); } }
public async Task WhenIRenderTheContentCalledToWithTheContext(string contentName, string outputName, string contextJson) { Content content = this.scenarioContext.Get <Content>(contentName); IContentRendererFactory rendererFactory = ContainerBindings.GetServiceProvider(this.featureContext).GetService <IContentRendererFactory>(); IContentRenderer renderer = rendererFactory.GetRendererFor(content.ContentPayload); using var stream = new MemoryStream(); using var writer = new StreamWriter(stream, Encoding.UTF8, 1024, true); await renderer.RenderAsync(writer, content, content.ContentPayload, new PropertyBag(JObject.Parse("{" + contextJson + "}"))).ConfigureAwait(false); await writer.FlushAsync().ConfigureAwait(false); stream.Position = 0; using var reader = new StreamReader(stream, Encoding.UTF8, true, 1024, true); this.scenarioContext.Set(await reader.ReadToEndAsync().ConfigureAwait(false), outputName); }
/// <inheritdoc/> public async Task RenderAsync(TextWriter output, Content parentContent, IContentPayload currentPayload, PropertyBag context) { if (!context.TryGet(AbTestIdContextKey, out string abTestId)) { throw new InvalidOperationException($"The context must contain the '{AbTestIdContextKey}' property"); } if (currentPayload is AbTestSetPayload testSet) { Content content = await testSet.GetContentForAbGroupAsync(abTestId).ConfigureAwait(false); IContentRenderer renderer = this.contentRendererFactory.GetRendererFor(content.ContentPayload); await renderer.RenderAsync(output, content, content.ContentPayload, context).ConfigureAwait(false); } else { throw new ArgumentException(nameof(currentPayload)); } }
/// <summary> /// Initializes a new instance of the <see cref="AlloyContentAreaRenderer"/> class. /// </summary> /// <param name="contentRenderer">The content renderer.</param> /// <param name="templateResolver">The template resolver.</param> /// <param name="attributeAssembler">The attribute assembler.</param> public AlloyContentAreaRenderer(IContentRenderer contentRenderer, TemplateResolver templateResolver, ContentFragmentAttributeAssembler attributeAssembler) : base(contentRenderer, templateResolver, attributeAssembler) { }
/// <summary> /// Initializes a new instance of the <see cref="AlloyContentAreaRenderer"/> class. /// </summary> /// <param name="contentRenderer">The content renderer.</param> /// <param name="templateResolver">The template resolver.</param> /// <param name="attributeAssembler">The attribute assembler.</param> public AlloyContentAreaRenderer(IContentRenderer contentRenderer, TemplateResolver templateResolver, ContentFragmentAttributeAssembler attributeAssembler) : base(contentRenderer, templateResolver, attributeAssembler) { }
public NoWrappersContentAreaRenderer(IContentRenderer contentRenderer, TemplateResolver templateResolver) { _contentRenderer = contentRenderer; _templateResolver = templateResolver; }
public SliderContentAreaRenderer(IContentRenderer contentRenderer, IContentRepository contentRepository) { _contentRenderer = contentRenderer; _contentRepository = contentRepository; }
/// <summary> /// Adds a renderer to the collection. /// </summary> /// <param name="renderer"></param> public void AddRenderer(IContentRenderer renderer) { _renderers.Add(renderer); }
/// <summary> /// Adds a contentrenderer to the rendering pipeline. /// </summary> /// <param name="renderer"></param> public void AddRenderer(IContentRenderer renderer) { _contentRendererCollection.AddRenderer(renderer); }
public SliderContentAreaRenderer(IContentRenderer contentRenderer, IContentRepository contentRepository) { _contentRenderer = contentRenderer; _contentRepository = contentRepository; }
public ContentRendererInterceptor(IContentRenderer defaultRenderer) { _defaultRenderer = defaultRenderer; }
public GetRecommendationsRequestHandler(IContentRenderer contentRenderer, IDownstreamRequestSender sender, IOptions <RecommendationOptions> options) { _sender = sender; _options = options.Value; _contentRenderer = contentRenderer; }
private ICacheableContentRendererService ContentRendererFactory(IServiceLocator serviceLocator, IContentRenderer contentRenderer) { return(new CacheableContentRendererService( contentRenderer, serviceLocator.GetInstance <ICacheableSettingsService>(), serviceLocator.GetInstance <ISynchronizedObjectInstanceCache>(), serviceLocator.GetInstance <ICacheableKeyCreator>(), serviceLocator.GetInstance <IContentCacheKeyCreator>())); }