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);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PublicationWorkflowContentRenderer"/> class.
 /// </summary>
 /// <param name="contentRendererFactory">The <see cref="IContentRendererFactory"/> used to create renderers for child content.</param>
 /// <param name="contentStore">The content store.</param>
 public PublicationWorkflowContentRenderer(IContentRendererFactory contentRendererFactory, IContentStore contentStore)
 {
     this.contentRendererFactory = contentRendererFactory;
     this.contentStore           = contentStore;
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AbTestSetRenderer"/> class.
 /// </summary>
 /// <param name="contentRendererFactory">The <see cref="IContentRendererFactory"/> used to create renderers for child content.</param>
 public AbTestSetRenderer(IContentRendererFactory contentRendererFactory)
 {
     this.contentRendererFactory = contentRendererFactory;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CompoundContentReferenceRenderer"/> class.
 /// </summary>
 /// <param name="contentRendererFactory">The <see cref="IContentRendererFactory"/> used to create renderers for child content.</param>
 /// <param name="contentStore">The content store from which content can be retrieved.</param>
 public CompoundContentReferenceRenderer(IContentRendererFactory contentRendererFactory, IContentStore contentStore)
 {
     this.contentRendererFactory = contentRendererFactory;
     this.contentStore           = contentStore;
 }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompoundPayloadRenderer"/> class.
 /// </summary>
 /// <param name="contentRendererFactory">The <see cref="IContentRendererFactory"/> used to create renderers for child content.</param>
 public CompoundPayloadRenderer(IContentRendererFactory contentRendererFactory)
 {
     this.contentRendererFactory = contentRendererFactory;
 }