コード例 #1
0
        private IEnumerable<IRenderingJob> CreateRenderingJobs(FileSystemInfo inputPath,
                                                           IBatchRenderingOptions inputOutputInfo,
                                                           RenderingMode? mode)
        {
            IEnumerable<IRenderingJob> output;

              if(inputPath != null && (inputPath is FileInfo))
              {
            output = new [] { CreateRenderingJob((FileInfo) inputPath, mode, inputPath.GetParentDirectory()) };
              }
              else if(inputPath != null && (inputPath is DirectoryInfo))
              {
            var dir = (DirectoryInfo) inputPath;

            output = (from file in dir.GetFiles(inputOutputInfo.InputSearchPattern, SearchOption.AllDirectories)
                  where  !inputOutputInfo.IgnoredPaths.Any(x => file.IsChildOf(x))
                  select CreateRenderingJob(file, mode, dir));
              }
              else
              {
            output = new IRenderingJob[0];
              }

              return output;
        }
コード例 #2
0
        /// <summary>
        /// Validate the given options.
        /// </summary>
        /// <param name="options">The options to validate.</param>
        public void Validate(IBatchRenderingOptions options)
        {
            if(options == null)
              {
            throw new ArgumentNullException(nameof(options));
              }

              if(options.InputStream == null && !options.InputPaths.Any())
              {
            string message = Resources.ExceptionMessages.BatchOptionsMustHaveInputStreamOrPaths;
            throw new InvalidBatchRenderingOptionsException(message, BatchRenderingFatalErrorType.NoInputsSpecified);
              }
              else if(options.InputStream != null && options.InputPaths.Any())
              {
            string message = Resources.ExceptionMessages.BatchOptionsMustNotHaveBothInputStreamAndPaths;
            throw new InvalidBatchRenderingOptionsException(message, BatchRenderingFatalErrorType.InputCannotBeBothStreamAndPaths);
              }

              if(options.OutputStream == null && options.OutputPath == null)
              {
            string message = Resources.ExceptionMessages.BatchOptionsMustHaveOutputStreamOrPath;
            throw new InvalidBatchRenderingOptionsException(message, BatchRenderingFatalErrorType.NoOutputsSpecified);
              }
              else if(options.OutputStream != null && options.OutputPath != null)
              {
            string message = Resources.ExceptionMessages.BatchOptionsMustNotHaveBothOutputStreamAndPath;
            throw new InvalidBatchRenderingOptionsException(message, BatchRenderingFatalErrorType.OutputCannotBeBothStreamAndPaths);
              }
        }
コード例 #3
0
        /// <summary>
        /// Gets the rendering jobs from the batch rendering options.
        /// </summary>
        /// <returns>The rendering jobs.</returns>
        /// <param name="inputOutputInfo">Input output info.</param>
        /// <param name="mode">Mode.</param>
        public IEnumerable<IRenderingJob> GetRenderingJobs(IBatchRenderingOptions inputOutputInfo,
                                                       RenderingMode? mode)
        {
            IEnumerable<IRenderingJob> output;

              if(inputOutputInfo.InputStream != null)
              {
            output = ReadFromStream(inputOutputInfo.InputStream, mode);
              }
              else
              {
            output = ReadFromInputPaths(inputOutputInfo, mode);
              }

              return output;
        }
コード例 #4
0
ファイル: BatchRenderer.cs プロジェクト: csf-dev/ZPT-Sharp
        /// <summary>
        /// Parse and render the documents found using the given batch rendering options.
        /// </summary>
        /// <param name="settings">Rendering settings.</param>
        /// <param name="batchOptions">Batch rendering options, indicating the source and destination files.</param>
        public virtual IBatchRenderingResponse Render(IBatchRenderingOptions batchOptions,
                                                  IRenderingSettings settings)
        {
            ValidateBatchOptions(batchOptions);

              var jobs = GetRenderingJobs(batchOptions, batchOptions.RenderingMode);

              List<IBatchRenderingDocumentResponse> documents = new List<IBatchRenderingDocumentResponse>();

              foreach(var job in jobs)
              {
            var contextConfigurator = GetContextConfigurator(job);

            var docResponse = Render(job, settings, batchOptions, contextConfigurator);
            documents.Add(docResponse);
              }

              return new BatchRenderingResponse(documents);
        }
コード例 #5
0
ファイル: RenderingJob.cs プロジェクト: csf-dev/ZPT-Sharp
        public Stream GetOutputStream(IBatchRenderingOptions batchOptions)
        {
            if(batchOptions == null)
              {
            throw new ArgumentNullException(nameof(batchOptions));
              }

              Stream output;

              if(batchOptions.OutputStream != null)
              {
            output = batchOptions.OutputStream;
              }
              else
              {
            var outputFile = GetOutputFile(batchOptions);
            output = GetOutputStream(outputFile);
              }

              return output;
        }
コード例 #6
0
ファイル: RenderingJob.cs プロジェクト: csf-dev/ZPT-Sharp
        public string GetOutputInfo(IBatchRenderingOptions batchOptions)
        {
            if(batchOptions == null)
              {
            throw new ArgumentNullException(nameof(batchOptions));
              }

              string output;

              if(batchOptions.OutputStream != null)
              {
            output = "STDOUT";
              }
              else
              {
            var outputFile = GetOutputFile(batchOptions);
            output = outputFile.FullName;
              }

              return output;
        }
コード例 #7
0
ファイル: BatchRenderer.cs プロジェクト: csf-dev/ZPT-Sharp
 /// <summary>
 /// Parse and render the documents found using the given batch rendering options.
 /// </summary>
 /// <param name="options">Rendering options.</param>
 /// <param name="batchOptions">Batch rendering options, indicating the source and destination files.</param>
 /// <returns>
 /// An object instance indicating the outcome of the rendering.
 /// </returns>
 public virtual IBatchRenderingResponse Render(IBatchRenderingOptions batchOptions,
                                           IRenderingOptions options = null)
 {
     return this.Render(batchOptions, _settingsFactory.CreateSettings(options));
 }
コード例 #8
0
ファイル: BatchRenderer.cs プロジェクト: csf-dev/ZPT-Sharp
 /// <summary>
 /// Validates the batch rendering options.
 /// </summary>
 /// <param name="options">Options.</param>
 protected virtual void ValidateBatchOptions(IBatchRenderingOptions options)
 {
     _optionsValidator.Validate(options);
 }
コード例 #9
0
ファイル: BatchRenderer.cs プロジェクト: csf-dev/ZPT-Sharp
        /// <summary>
        /// Renders a single rendering job and returns a response.
        /// </summary>
        /// <param name="job">The job to render.</param>
        /// <param name="options">Rendering options.</param>
        /// <param name="batchOptions">Batch rendering options.</param>
        /// <param name="contextConfigurator">Context configurator.</param>
        protected virtual IBatchRenderingDocumentResponse Render(IRenderingJob job,
                                                             IRenderingSettings options,
                                                             IBatchRenderingOptions batchOptions,
                                                             Action<IModelValueContainer> contextConfigurator)
        {
            var doc = GetDocument(job);
              var outputInfo = GetOutputInfo(job, batchOptions);

              using(var outputStream = GetOutputStream(job, batchOptions))
              {
            return Render(doc, outputStream, options, contextConfigurator, outputInfo);
              }
        }
コード例 #10
0
ファイル: BatchRenderer.cs プロジェクト: csf-dev/ZPT-Sharp
 /// <summary>
 /// Gets the rendering jobs from the rendering job factory.
 /// </summary>
 /// <returns>The rendering jobs.</returns>
 /// <param name="options">Batch rendering options.</param>
 /// <param name="mode">An optional rendering mode override.</param>
 protected virtual IEnumerable<IRenderingJob> GetRenderingJobs(IBatchRenderingOptions options, RenderingMode? mode)
 {
     return _jobFactory.GetRenderingJobs(options, mode);
 }
コード例 #11
0
ファイル: BatchRenderer.cs プロジェクト: csf-dev/ZPT-Sharp
 /// <summary>
 /// Gets the output stream for a given rendering job.
 /// </summary>
 /// <returns>The output stream.</returns>
 /// <param name="job">Job.</param>
 /// <param name="batchOptions">Batch options.</param>
 protected virtual Stream GetOutputStream(IRenderingJob job, IBatchRenderingOptions batchOptions)
 {
     return job.GetOutputStream(batchOptions);
 }
コード例 #12
0
ファイル: BatchRenderer.cs プロジェクト: csf-dev/ZPT-Sharp
 /// <summary>
 /// Gets the output info for a given rendering job.
 /// </summary>
 /// <returns>The output info.</returns>
 /// <param name="job">Job.</param>
 /// <param name="batchOptions">Batch options.</param>
 protected virtual string GetOutputInfo(IRenderingJob job, IBatchRenderingOptions batchOptions)
 {
     return job.GetOutputInfo(batchOptions);
 }
コード例 #13
0
 private void ExerciseSut()
 {
     _result = _sut.GetBatchOptions(_options);
 }
コード例 #14
0
ファイル: RenderingJob.cs プロジェクト: csf-dev/ZPT-Sharp
        private FileInfo GetOutputFile(IBatchRenderingOptions batchOptions)
        {
            FileInfo output;

              if(batchOptions.OutputPath is FileInfo)
              {
            output = (FileInfo) batchOptions.OutputPath;
              }
              else if(batchOptions.OutputPath is DirectoryInfo)
              {
            output = GetOutputFile((DirectoryInfo) batchOptions.OutputPath, batchOptions.OutputExtensionOverride);
              }
              else
              {
            throw new BatchRenderingException(Resources.ExceptionMessages.InvalidBatchRenderingOutputPath);
              }

              return output;
        }
コード例 #15
0
 private IEnumerable<IRenderingJob> ReadFromInputPaths(IBatchRenderingOptions inputOutputInfo,
                                                   RenderingMode? mode)
 {
     return inputOutputInfo.InputPaths.SelectMany(x => CreateRenderingJobs(x, inputOutputInfo, mode));
 }