public DocumentViewerContent CreateContent(IDocumentViewer documentViewer, IContentType contentType)
        {
            if (documentViewerOutput == null)
            {
                throw new InvalidOperationException();
            }
            if (documentViewer == null)
            {
                throw new ArgumentNullException(nameof(documentViewer));
            }
            if (contentType == null)
            {
                throw new ArgumentNullException(nameof(contentType));
            }

            documentViewerOutput.SetStatePostProcessing();
            using (var context = new DocumentViewerPostProcessorContext(documentViewerOutput, documentViewer, documentViewerOutput.GetCachedText(), contentType)) {
                foreach (var lz in documentViewerPostProcessors)
                {
                    lz.Value.PostProcess(context);
                }
            }

            documentViewerOutput.SetStateCustomDataProviders();
            using (var context = new DocumentViewerCustomDataContext(documentViewer, documentViewerOutput.GetCachedText(), contentType, documentViewerOutput.GetCustomDataDictionary())) {
                foreach (var lz in documentViewerCustomDataProviders)
                {
                    lz.Value.OnCustomData(context);
                }
                var output = documentViewerOutput;
                documentViewerOutput = null;
                return(output.CreateContent(context.GetResultDictionary()));
            }
        }
 public DocumentViewerContentFactory(Lazy <IDocumentViewerCustomDataProvider, IDocumentViewerCustomDataProviderMetadata>[] documentViewerCustomDataProviders)
 {
     if (documentViewerCustomDataProviders == null)
     {
         throw new ArgumentNullException(nameof(documentViewerCustomDataProviders));
     }
     this.documentViewerCustomDataProviders = documentViewerCustomDataProviders;
     this.documentViewerOutput = DocumentViewerOutput.Create();
 }
        public DocumentViewerContent CreateContent(IDocumentViewer documentViewer)
        {
            if (documentViewerOutput == null)
            {
                throw new InvalidOperationException();
            }
            if (documentViewer == null)
            {
                throw new ArgumentNullException(nameof(documentViewer));
            }

            using (var context = new DocumentViewerCustomDataContext(documentViewer, documentViewerOutput.GetCachedText(), documentViewerOutput.GetCustomDataDictionary())) {
                foreach (var lazy in documentViewerCustomDataProviders)
                {
                    lazy.Value.OnCustomData(context);
                }
                var output = documentViewerOutput;
                documentViewerOutput = null;
                return(output.CreateContent(context.GetResultDictionary()));
            }
        }
 public DocumentViewerContentFactory(Lazy <IDocumentViewerPostProcessor, IDocumentViewerPostProcessorMetadata>[] documentViewerPostProcessors, Lazy <IDocumentViewerCustomDataProvider, IDocumentViewerCustomDataProviderMetadata>[] documentViewerCustomDataProviders)
 {
     this.documentViewerPostProcessors      = documentViewerPostProcessors ?? throw new ArgumentNullException(nameof(documentViewerPostProcessors));
     this.documentViewerCustomDataProviders = documentViewerCustomDataProviders ?? throw new ArgumentNullException(nameof(documentViewerCustomDataProviders));
     documentViewerOutput = DocumentViewerOutput.Create();
 }